diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-02-24 02:42:00 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-02-24 02:42:00 (GMT) |
commit | 7c76abb0dc4204043bec9b6fa315f9753a7986ae (patch) | |
tree | cee303672cfd138790645e731f2d69472564d4b7 /tests/auto/declarative/qdeclarativeflickable | |
parent | 4066e60e859853cfe3240245ba05271e79839506 (diff) | |
download | Qt-7c76abb0dc4204043bec9b6fa315f9753a7986ae.zip Qt-7c76abb0dc4204043bec9b6fa315f9753a7986ae.tar.gz Qt-7c76abb0dc4204043bec9b6fa315f9753a7986ae.tar.bz2 |
Change class prefix to from QmlXXX to QDeclarativeXXX, QmlGraphicsXXX to QDeclarativeXXX.
Diffstat (limited to 'tests/auto/declarative/qdeclarativeflickable')
6 files changed, 280 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable01.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable01.qml new file mode 100644 index 0000000..8a1843c --- /dev/null +++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable01.qml @@ -0,0 +1,4 @@ +import Qt 4.6 + +Flickable { +} diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable02.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable02.qml new file mode 100644 index 0000000..3e08359 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable02.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Flickable { + width: 100; height: 100 + viewportWidth: row.width; viewportHeight: row.height + + Row { + id: row + Repeater { + model: 4 + Rectangle { width: 200; height: 300; color: "blue" } + } + } +} diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml new file mode 100644 index 0000000..3ed173d --- /dev/null +++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable03.qml @@ -0,0 +1,14 @@ +import Qt 4.6 + +Flickable { + width: 100; height: 100 + viewportWidth: column.width; viewportHeight: column.height + + Column { + id: column + Repeater { + model: 4 + Rectangle { width: 200; height: 300; color: "blue" } + } + } +} diff --git a/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml b/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml new file mode 100644 index 0000000..1425d85 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeflickable/data/flickable04.qml @@ -0,0 +1,16 @@ +import Qt 4.6 + +Flickable { + width: 100; height: 100 + viewportWidth: column.width; viewportHeight: column.height + pressDelay: 200; overShoot: false; interactive: false + maximumFlickVelocity: 2000 + + Column { + id: column + Repeater { + model: 4 + Rectangle { width: 200; height: 300; color: "blue" } + } + } +} diff --git a/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro new file mode 100644 index 0000000..4b71381 --- /dev/null +++ b/tests/auto/declarative/qdeclarativeflickable/qdeclarativeflickable.pro @@ -0,0 +1,8 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui +macx:CONFIG -= app_bundle + +SOURCES += tst_qdeclarativeflickable.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp new file mode 100644 index 0000000..9e5238e --- /dev/null +++ b/tests/auto/declarative/qdeclarativeflickable/tst_qdeclarativeflickable.cpp @@ -0,0 +1,224 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#include <qtest.h> +#include <QtTest/QSignalSpy> +#include <QtDeclarative/qdeclarativeengine.h> +#include <QtDeclarative/qdeclarativecomponent.h> +#include <private/qdeclarativeflickable_p.h> +#include <private/qdeclarativevaluetype_p.h> +#include <math.h> + +class tst_qmlgraphicsflickable : public QObject +{ + Q_OBJECT +public: + tst_qmlgraphicsflickable(); + +private slots: + void create(); + void horizontalViewportSize(); + void verticalViewportSize(); + void properties(); + void overShoot(); + void maximumFlickVelocity(); + void flickDeceleration(); + void pressDelay(); + +private: + QDeclarativeEngine engine; +}; + +tst_qmlgraphicsflickable::tst_qmlgraphicsflickable() +{ +} + +void tst_qmlgraphicsflickable::create() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable01.qml")); + QDeclarativeFlickable *obj = qobject_cast<QDeclarativeFlickable*>(c.create()); + + QVERIFY(obj != 0); + QCOMPARE(obj->isAtXBeginning(), true); + QCOMPARE(obj->isAtXEnd(), false); + QCOMPARE(obj->isAtYBeginning(), true); + QCOMPARE(obj->isAtYEnd(), false); + QCOMPARE(obj->viewportX(), 0.); + QCOMPARE(obj->viewportY(), 0.); + + QCOMPARE(obj->horizontalVelocity(), 0.); + QCOMPARE(obj->verticalVelocity(), 0.); + QCOMPARE(obj->reportedVelocitySmoothing(), 100.); + + QCOMPARE(obj->isInteractive(), true); + QCOMPARE(obj->overShoot(), true); + QCOMPARE(obj->pressDelay(), 0); + QCOMPARE(obj->maximumFlickVelocity(), 2000.); + + delete obj; +} + +void tst_qmlgraphicsflickable::horizontalViewportSize() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable02.qml")); + QDeclarativeFlickable *obj = qobject_cast<QDeclarativeFlickable*>(c.create()); + + QVERIFY(obj != 0); + QCOMPARE(obj->viewportWidth(), 800.); + QCOMPARE(obj->viewportHeight(), 300.); + QCOMPARE(obj->isAtXBeginning(), true); + QCOMPARE(obj->isAtXEnd(), false); + QCOMPARE(obj->isAtYBeginning(), true); + QCOMPARE(obj->isAtYEnd(), false); + + delete obj; +} + +void tst_qmlgraphicsflickable::verticalViewportSize() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable03.qml")); + QDeclarativeFlickable *obj = qobject_cast<QDeclarativeFlickable*>(c.create()); + + QVERIFY(obj != 0); + QCOMPARE(obj->viewportWidth(), 200.); + QCOMPARE(obj->viewportHeight(), 1200.); + QCOMPARE(obj->isAtXBeginning(), true); + QCOMPARE(obj->isAtXEnd(), false); + QCOMPARE(obj->isAtYBeginning(), true); + QCOMPARE(obj->isAtYEnd(), false); + + delete obj; +} + +void tst_qmlgraphicsflickable::properties() +{ + QDeclarativeEngine engine; + QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/flickable04.qml")); + QDeclarativeFlickable *obj = qobject_cast<QDeclarativeFlickable*>(c.create()); + + QVERIFY(obj != 0); + QCOMPARE(obj->isInteractive(), false); + QCOMPARE(obj->overShoot(), false); + QCOMPARE(obj->pressDelay(), 200); + QCOMPARE(obj->maximumFlickVelocity(), 2000.); + + delete obj; +} + +void tst_qmlgraphicsflickable::overShoot() +{ + QDeclarativeComponent component(&engine); + component.setData("import Qt 4.6; Flickable { overShoot: false; }", QUrl::fromLocalFile("")); + QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(component.create()); + QSignalSpy spy(flickable, SIGNAL(overShootChanged())); + + QVERIFY(flickable); + QVERIFY(!flickable->overShoot()); + + flickable->setOverShoot(true); + QVERIFY(flickable->overShoot()); + QCOMPARE(spy.count(),1); + flickable->setOverShoot(true); + QCOMPARE(spy.count(),1); + + flickable->setOverShoot(false); + QVERIFY(!flickable->overShoot()); + QCOMPARE(spy.count(),2); + flickable->setOverShoot(false); + QCOMPARE(spy.count(),2); +} + +void tst_qmlgraphicsflickable::maximumFlickVelocity() +{ + QDeclarativeComponent component(&engine); + component.setData("import Qt 4.6; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile("")); + QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(component.create()); + QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->maximumFlickVelocity(), 1.0); + + flickable->setMaximumFlickVelocity(2.0); + QCOMPARE(flickable->maximumFlickVelocity(), 2.0); + QCOMPARE(spy.count(),1); + flickable->setMaximumFlickVelocity(2.0); + QCOMPARE(spy.count(),1); +} + +void tst_qmlgraphicsflickable::flickDeceleration() +{ + QDeclarativeComponent component(&engine); + component.setData("import Qt 4.6; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile("")); + QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(component.create()); + QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->flickDeceleration(), 1.0); + + flickable->setFlickDeceleration(2.0); + QCOMPARE(flickable->flickDeceleration(), 2.0); + QCOMPARE(spy.count(),1); + flickable->setFlickDeceleration(2.0); + QCOMPARE(spy.count(),1); +} + +void tst_qmlgraphicsflickable::pressDelay() +{ + QDeclarativeComponent component(&engine); + component.setData("import Qt 4.6; Flickable { pressDelay: 100; }", QUrl::fromLocalFile("")); + QDeclarativeFlickable *flickable = qobject_cast<QDeclarativeFlickable*>(component.create()); + QSignalSpy spy(flickable, SIGNAL(pressDelayChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->pressDelay(), 100); + + flickable->setPressDelay(200); + QCOMPARE(flickable->pressDelay(), 200); + QCOMPARE(spy.count(),1); + flickable->setPressDelay(200); + QCOMPARE(spy.count(),1); +} + +QTEST_MAIN(tst_qmlgraphicsflickable) + +#include "tst_qdeclarativeflickable.moc" |