diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2009-11-11 06:42:22 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2009-11-11 06:42:22 (GMT) |
commit | 49e1b989213028dac8557d4e74ab530f77fc8a07 (patch) | |
tree | aa2aae204ec1ed6de623500c2d9d9034fd2500ab /tests/auto/declarative/qmlgraphicspathview | |
parent | 7df3dce47c1ed9545065f60c3faebdd31d922a38 (diff) | |
download | Qt-49e1b989213028dac8557d4e74ab530f77fc8a07.zip Qt-49e1b989213028dac8557d4e74ab530f77fc8a07.tar.gz Qt-49e1b989213028dac8557d4e74ab530f77fc8a07.tar.bz2 |
basic PathView autotests
Diffstat (limited to 'tests/auto/declarative/qmlgraphicspathview')
5 files changed, 250 insertions, 0 deletions
diff --git a/tests/auto/declarative/qmlgraphicspathview/data/pathview1.qml b/tests/auto/declarative/qmlgraphicspathview/data/pathview1.qml new file mode 100644 index 0000000..b3b0a9a --- /dev/null +++ b/tests/auto/declarative/qmlgraphicspathview/data/pathview1.qml @@ -0,0 +1,4 @@ +import Qt 4.6 + +PathView { +} diff --git a/tests/auto/declarative/qmlgraphicspathview/data/pathview2.qml b/tests/auto/declarative/qmlgraphicspathview/data/pathview2.qml new file mode 100644 index 0000000..0d5c98b --- /dev/null +++ b/tests/auto/declarative/qmlgraphicspathview/data/pathview2.qml @@ -0,0 +1,57 @@ +import Qt 4.6 + +PathView { + id: photoPathView; model: rssModel; delegate: photoDelegate + 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/declarative/qmlgraphicspathview/data/pathview3.qml b/tests/auto/declarative/qmlgraphicspathview/data/pathview3.qml new file mode 100644 index 0000000..a8c1e91 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicspathview/data/pathview3.qml @@ -0,0 +1,58 @@ +import Qt 4.6 + +PathView { + id: photoPathView; model: rssModel; delegate: photoDelegate + y: 100; width: 800; height: 330; pathItemCount: 4; offset: 10 + dragMargin: 24; snapPosition: 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 + 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/declarative/qmlgraphicspathview/qmlgraphicspathview.pro b/tests/auto/declarative/qmlgraphicspathview/qmlgraphicspathview.pro new file mode 100644 index 0000000..142a256 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicspathview/qmlgraphicspathview.pro @@ -0,0 +1,8 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +macx:CONFIG -= app_bundle + +SOURCES += tst_qmlgraphicspathview.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp new file mode 100644 index 0000000..c36b969 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp @@ -0,0 +1,123 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <private/qmlgraphicspathview_p.h> +#include <qmlcontext.h> +#include <qmlexpression.h> +#include <qtest.h> +#include <QtDeclarative/qmlengine.h> +#include <QtDeclarative/qmlcomponent.h> +#include <private/qmlvaluetype_p.h> +#include "../../../shared/util.h" + +class tst_QmlGraphicsPathView : public QObject +{ + Q_OBJECT +public: + tst_QmlGraphicsPathView(); + +private slots: + void initValues(); + void pathview2(); + void pathview3(); +}; + + +tst_QmlGraphicsPathView::tst_QmlGraphicsPathView() +{ +} + +void tst_QmlGraphicsPathView::initValues() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/pathview1.qml")); + QmlGraphicsPathView *obj = qobject_cast<QmlGraphicsPathView*>(c.create()); + + QVERIFY(obj != 0); + QVERIFY(obj->path() == 0); + QVERIFY(obj->delegate() == 0); + QCOMPARE(obj->model(), QVariant()); + QCOMPARE(obj->currentIndex(), 0); + QCOMPARE(obj->offset(), 0.); + QCOMPARE(obj->snapPosition(), 0.); + QCOMPARE(obj->dragMargin(), 0.); + QCOMPARE(obj->count(), 0); + QCOMPARE(obj->pathItemCount(), -1); +} + +void tst_QmlGraphicsPathView::pathview2() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/pathview2.qml")); + QmlGraphicsPathView *obj = qobject_cast<QmlGraphicsPathView*>(c.create()); + + QVERIFY(obj != 0); + QVERIFY(obj->path() != 0); + QVERIFY(obj->delegate() != 0); + QVERIFY(obj->model() != QVariant()); + QCOMPARE(obj->currentIndex(), 0); + QCOMPARE(obj->offset(), 0.); + QCOMPARE(obj->snapPosition(), 0.); + QCOMPARE(obj->dragMargin(), 0.); + QCOMPARE(obj->count(), 8); + QCOMPARE(obj->pathItemCount(), 10); +} + +void tst_QmlGraphicsPathView::pathview3() +{ + QmlEngine engine; + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/pathview3.qml")); + QmlGraphicsPathView *obj = qobject_cast<QmlGraphicsPathView*>(c.create()); + + QVERIFY(obj != 0); + QVERIFY(obj->path() != 0); + QVERIFY(obj->delegate() != 0); + QVERIFY(obj->model() != QVariant()); + QCOMPARE(obj->currentIndex(), 0); + QCOMPARE(obj->offset(), 50.); // ??? + QCOMPARE(obj->snapPosition(), 0.5); // ??? + QCOMPARE(obj->dragMargin(), 24.); + QCOMPARE(obj->count(), 8); + QCOMPARE(obj->pathItemCount(), 4); +} + +QTEST_MAIN(tst_QmlGraphicsPathView) + +#include "tst_qmlgraphicspathview.moc" |