diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-05-11 23:24:30 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-05-11 23:24:30 (GMT) |
commit | 6527735ff53a8ec593f5f85b037de46059e1207e (patch) | |
tree | 47f03f1bc910687fb34a20f044cafbdb9fd29744 /tests | |
parent | 0b9a6b9014aa2771aedaa9b6de02c1777b35e06b (diff) | |
download | Qt-6527735ff53a8ec593f5f85b037de46059e1207e.zip Qt-6527735ff53a8ec593f5f85b037de46059e1207e.tar.gz Qt-6527735ff53a8ec593f5f85b037de46059e1207e.tar.bz2 |
Ensure PathView "attribute" attached properties are created correctly
If an item was created spontaneously (i.e. delegate is a package and
some other view created the item), ensure its attached properties are
correctly initialized.
Task-number: QTBUG-10527
Diffstat (limited to 'tests')
-rw-r--r-- | tests/auto/declarative/qdeclarativepathview/data/pathview_package.qml | 88 | ||||
-rw-r--r-- | tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp | 17 |
2 files changed, 105 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativepathview/data/pathview_package.qml b/tests/auto/declarative/qdeclarativepathview/data/pathview_package.qml new file mode 100644 index 0000000..082da13 --- /dev/null +++ b/tests/auto/declarative/qdeclarativepathview/data/pathview_package.qml @@ -0,0 +1,88 @@ +import Qt 4.7 + +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/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp index c32e9cc..62d0b89 100644 --- a/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp +++ b/tests/auto/declarative/qdeclarativepathview/tst_qdeclarativepathview.cpp @@ -78,6 +78,7 @@ private slots: void componentChanges(); void modelChanges(); void pathUpdateOnStartChanged(); + void package(); private: @@ -695,6 +696,22 @@ void tst_QDeclarativePathView::pathUpdateOnStartChanged() delete canvas; } +void tst_QDeclarativePathView::package() +{ + QDeclarativeView *canvas = createView(); + QVERIFY(canvas); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview_package.qml")); + + QDeclarativePathView *pathView = canvas->rootObject()->findChild<QDeclarativePathView*>("photoPathView"); + QVERIFY(pathView); + + QDeclarativeItem *item = findItem<QDeclarativeItem>(pathView, "pathItem"); + QVERIFY(item); + QVERIFY(item->scale() != 1.0); + + delete canvas; +} + QDeclarativeView *tst_QDeclarativePathView::createView() { QDeclarativeView *canvas = new QDeclarativeView(0); |