diff options
author | Warwick Allison <warwick.allison@nokia.com> | 2010-02-23 23:31:31 (GMT) |
---|---|---|
committer | Warwick Allison <warwick.allison@nokia.com> | 2010-02-23 23:31:31 (GMT) |
commit | ec7ac34b4a6b1a330460838acc74a53d29f62a7c (patch) | |
tree | 5505189d15ce0a1f3b67f4cd65e4c39766080a1d /tests | |
parent | 8727985d81c793d52d5e24ed6815e7237ae879f1 (diff) | |
parent | d19f691a5646725c69b232e2adde8c2f961eb571 (diff) | |
download | Qt-ec7ac34b4a6b1a330460838acc74a53d29f62a7c.zip Qt-ec7ac34b4a6b1a330460838acc74a53d29f62a7c.tar.gz Qt-ec7ac34b4a6b1a330460838acc74a53d29f62a7c.tar.bz2 |
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt-qml
Conflicts:
src/declarative/util/qmlanimation.cpp
src/declarative/util/qmlxmllistmodel.cpp
Diffstat (limited to 'tests')
46 files changed, 1049 insertions, 267 deletions
diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp index ee05574..53c1ede 100644 --- a/tests/auto/declarative/layouts/tst_layouts.cpp +++ b/tests/auto/declarative/layouts/tst_layouts.cpp @@ -67,7 +67,6 @@ void tst_QmlGraphicsLayouts::test_qml() { QmlView *canvas = createView(SRCDIR "/data/layouts.qml"); - canvas->execute(); qApp->processEvents(); QmlGraphicsLayoutItem *left = static_cast<QmlGraphicsLayoutItem*>(canvas->rootObject()->findChild<QmlGraphicsItem*>("left")); QVERIFY(left != 0); diff --git a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp index 9eae308..00e099e 100644 --- a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp +++ b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp @@ -45,6 +45,7 @@ #include <private/qmlgraphicsrectangle_p.h> #include <private/qmlanimation_p.h> #include <QVariantAnimation> +#include <QEasingCurve> class tst_qmlanimations : public QObject { @@ -67,11 +68,11 @@ private slots: void mixedTypes(); void properties(); void propertiesTransition(); - void easingStringConversion(); void invalidDuration(); void attached(); void propertyValueSourceDefaultStart(); void dontStart(); + void easingProperties(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -261,7 +262,6 @@ void tst_qmlanimations::badTypes() QmlView *view = new QmlView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml")); - view->execute(); qApp->processEvents(); delete view; @@ -518,57 +518,6 @@ void tst_qmlanimations::propertiesTransition() }*/ } -void tst_qmlanimations::easingStringConversion() -{ - QmlNumberAnimation *animation = new QmlNumberAnimation; - animation->setEasing("easeInOutQuad"); - QCOMPARE(animation->easing(),QLatin1String("easeInOutQuad")); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::InOutQuad)); - - animation->setEasing("OutQuad"); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve(), QEasingCurve(QEasingCurve::OutQuad)); - - animation->setEasing("easeOutBounce(amplitude: 5)"); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutBounce); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude(), qreal(5)); - - animation->setEasing("easeOutElastic(amplitude: 5, period: 3)"); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutElastic); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude(), qreal(5)); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().period(), qreal(3)); - - animation->setEasing("easeInOutBack(overshoot: 2)"); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutBack); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().overshoot(), qreal(2)); - - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unmatched parenthesis in easing function \"easeInOutBack(overshoot: 2\""); - animation->setEasing("easeInOutBack(overshoot: 2"); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::Linear); - - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Easing function \"InOutBack(overshoot: 2)\" must start with \"ease\""); - animation->setEasing("InOutBack(overshoot: 2)"); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::Linear); - - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing curve \"NonExistantEase\""); - animation->setEasing("NonExistantEase"); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::Linear); - - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Improperly specified parameter in easing function \"easeInOutElastic(amplitude 5)\""); - animation->setEasing("easeInOutElastic(amplitude 5)"); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutElastic); - - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Improperly specified parameter in easing function \"easeInOutElastic(amplitude: yes)\""); - animation->setEasing("easeInOutElastic(amplitude: yes)"); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::InOutElastic); - QVERIFY(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().amplitude() != qreal(5)); - - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (unknown location) Unknown easing parameter \"nonexistentproperty\""); - animation->setEasing("easeOutQuad(nonexistentproperty: 12)"); - QCOMPARE(static_cast<QVariantAnimation*>(((QmlAbstractAnimation*)animation)->qtAnimation())->easingCurve().type(), QEasingCurve::OutQuad); - - delete animation; -} - void tst_qmlanimations::invalidDuration() { QmlPropertyAnimation *animation = new QmlPropertyAnimation; @@ -667,6 +616,57 @@ void tst_qmlanimations::dontStart() } } +void tst_qmlanimations::easingProperties() +{ + { + QmlEngine engine; + QString componentStr = "import Qt 4.6\nNumberAnimation { easing.type: \"InOutQuad\" }"; + QmlComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QmlPropertyAnimation *animObject = qobject_cast<QmlPropertyAnimation*>(animationComponent.create()); + + QVERIFY(animObject != 0); + QCOMPARE(animObject->easing().type(), QEasingCurve::InOutQuad); + } + + { + QmlEngine engine; + QString componentStr = "import Qt 4.6\nPropertyAnimation { easing.type: \"OutBounce\"; easing.amplitude: 5.0 }"; + QmlComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QmlPropertyAnimation *animObject = qobject_cast<QmlPropertyAnimation*>(animationComponent.create()); + + QVERIFY(animObject != 0); + QCOMPARE(animObject->easing().type(), QEasingCurve::OutBounce); + QCOMPARE(animObject->easing().amplitude(), 5.0); + } + + { + QmlEngine engine; + QString componentStr = "import Qt 4.6\nPropertyAnimation { easing.type: \"OutElastic\"; easing.amplitude: 5.0; easing.period: 3.0}"; + QmlComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QmlPropertyAnimation *animObject = qobject_cast<QmlPropertyAnimation*>(animationComponent.create()); + + QVERIFY(animObject != 0); + QCOMPARE(animObject->easing().type(), QEasingCurve::OutElastic); + QCOMPARE(animObject->easing().amplitude(), 5.0); + QCOMPARE(animObject->easing().period(), 3.0); + } + + { + QmlEngine engine; + QString componentStr = "import Qt 4.6\nPropertyAnimation { easing.type: \"InOutBack\"; easing.overshoot: 2 }"; + QmlComponent animationComponent(&engine); + animationComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QmlPropertyAnimation *animObject = qobject_cast<QmlPropertyAnimation*>(animationComponent.create()); + + QVERIFY(animObject != 0); + QCOMPARE(animObject->easing().type(), QEasingCurve::InOutBack); + QCOMPARE(animObject->easing().overshoot(), 2.0); + } +} + QTEST_MAIN(tst_qmlanimations) #include "tst_qmlanimations.moc" diff --git a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp index ba07331..2f1a557 100644 --- a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp +++ b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp @@ -51,8 +51,8 @@ #include <QtDeclarative/qmlexpression.h> #include <QtDeclarative/qmlmetatype.h> #include <QtDeclarative/qmlmetaproperty.h> -#include <QtDeclarative/qmlbinding.h> +#include <private/qmlbinding_p.h> #include <private/qmldebug_p.h> #include <private/qmlenginedebug_p.h> #include <private/qmldebugclient_p.h> diff --git a/tests/auto/declarative/qmlecmascript/testtypes.h b/tests/auto/declarative/qmlecmascript/testtypes.h index e1fb1b7..9d7d0a7 100644 --- a/tests/auto/declarative/qmlecmascript/testtypes.h +++ b/tests/auto/declarative/qmlecmascript/testtypes.h @@ -173,17 +173,21 @@ QML_DECLARE_TYPE(MyQmlContainer); class MyExpression : public QmlExpression { + Q_OBJECT public: MyExpression(QmlContext *ctxt, const QString &expr) : QmlExpression(ctxt, expr, 0), changed(false) { + QObject::connect(this, SIGNAL(valueChanged()), this, SLOT(expressionValueChanged())); + setNotifyOnValueChanged(true); } - void emitValueChanged() { + bool changed; + +public slots: + void expressionValueChanged() { changed = true; - QmlExpression::emitValueChanged(); } - bool changed; }; diff --git a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp index aa6b56a..721608e 100644 --- a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp +++ b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp @@ -104,7 +104,6 @@ void tst_qmlgraphicsanchors::basicAnchors() QmlView *view = new QmlView; view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml")); - view->execute(); qApp->processEvents(); //sibling horizontal @@ -171,28 +170,28 @@ void tst_qmlgraphicsanchors::basicAnchors() void tst_qmlgraphicsanchors::loops() { { - QmlView *view = new QmlView; - - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml")); + QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml")); - QString expect = "QML Text (" + view->source().toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor."; + QString expect = "QML Text (" + source.toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - view->execute(); + + QmlView *view = new QmlView; + view->setSource(source); qApp->processEvents(); delete view; } { - QmlView *view = new QmlView; + QUrl source(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml")); - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml")); - - QString expect = "QML Image (" + view->source().toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor."; + QString expect = "QML Image (" + source.toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); - view->execute(); + + QmlView *view = new QmlView; + view->setSource(source); qApp->processEvents(); delete view; @@ -370,14 +369,13 @@ void tst_qmlgraphicsanchors::nullItem_data() void tst_qmlgraphicsanchors::crash1() { - QmlView *view = new QmlView; + QUrl source(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml")); - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml")); - - QString expect = "QML Text (" + view->source().toString() + ":4:5" + ") Possible anchor loop detected on fill."; + QString expect = "QML Text (" + source.toString() + ":4:5" + ") Possible anchor loop detected on fill."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); // XXX ideally, should be one message - view->execute(); + + QmlView *view = new QmlView(source); qApp->processEvents(); delete view; @@ -385,11 +383,8 @@ void tst_qmlgraphicsanchors::crash1() void tst_qmlgraphicsanchors::fill() { - QmlView *view = new QmlView; - - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/fill.qml")); + QmlView *view = new QmlView(QUrl::fromLocalFile(SRCDIR "/data/fill.qml")); - view->execute(); qApp->processEvents(); QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("filler")); QCOMPARE(rect->x(), 0.0 + 10.0); @@ -411,11 +406,8 @@ void tst_qmlgraphicsanchors::fill() void tst_qmlgraphicsanchors::centerIn() { - QmlView *view = new QmlView; - - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml")); + QmlView *view = new QmlView(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml")); - view->execute(); qApp->processEvents(); QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("centered")); QCOMPARE(rect->x(), 75.0 + 10); @@ -431,11 +423,8 @@ void tst_qmlgraphicsanchors::centerIn() void tst_qmlgraphicsanchors::margins() { - QmlView *view = new QmlView; - - view->setSource(QUrl::fromLocalFile(SRCDIR "/data/margins.qml")); + QmlView *view = new QmlView(QUrl::fromLocalFile(SRCDIR "/data/margins.qml")); - view->execute(); qApp->processEvents(); QmlGraphicsRectangle* rect = findItem<QmlGraphicsRectangle>(view->rootObject(), QLatin1String("filler")); QCOMPARE(rect->x(), 5.0); diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp index 2520d4a..7c8501c 100644 --- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp +++ b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp @@ -68,7 +68,7 @@ private slots: void positionViewAtIndex(); private: - QmlView *createView(const QString &filename); + QmlView *createView(); template<typename T> T *findItem(QGraphicsObject *parent, const QString &id, int index=-1); template<typename T> @@ -142,7 +142,7 @@ tst_QmlGraphicsGridView::tst_QmlGraphicsGridView() void tst_QmlGraphicsGridView::items() { - QmlView *canvas = createView(SRCDIR "/data/gridview.qml"); + QmlView *canvas = createView(); TestModel model; model.addItem("Fred", "12345"); @@ -157,7 +157,7 @@ void tst_QmlGraphicsGridView::items() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml")); qApp->processEvents(); QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid"); @@ -190,7 +190,7 @@ void tst_QmlGraphicsGridView::items() void tst_QmlGraphicsGridView::changed() { - QmlView *canvas = createView(SRCDIR "/data/gridview.qml"); + QmlView *canvas = createView(); TestModel model; model.addItem("Fred", "12345"); @@ -205,7 +205,7 @@ void tst_QmlGraphicsGridView::changed() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml")); qApp->processEvents(); QmlGraphicsFlickable *gridview = findItem<QmlGraphicsFlickable>(canvas->rootObject(), "grid"); @@ -227,7 +227,7 @@ void tst_QmlGraphicsGridView::changed() void tst_QmlGraphicsGridView::inserted() { - QmlView *canvas = createView(SRCDIR "/data/gridview.qml"); + QmlView *canvas = createView(); TestModel model; model.addItem("Fred", "12345"); @@ -238,7 +238,7 @@ void tst_QmlGraphicsGridView::inserted() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml")); qApp->processEvents(); QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid"); @@ -309,7 +309,7 @@ void tst_QmlGraphicsGridView::inserted() void tst_QmlGraphicsGridView::removed() { - QmlView *canvas = createView(SRCDIR "/data/gridview.qml"); + QmlView *canvas = createView(); TestModel model; for (int i = 0; i < 40; i++) @@ -319,7 +319,7 @@ void tst_QmlGraphicsGridView::removed() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml")); qApp->processEvents(); QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid"); @@ -469,7 +469,7 @@ void tst_QmlGraphicsGridView::removed() void tst_QmlGraphicsGridView::moved() { - QmlView *canvas = createView(SRCDIR "/data/gridview.qml"); + QmlView *canvas = createView(); TestModel model; for (int i = 0; i < 30; i++) @@ -479,7 +479,7 @@ void tst_QmlGraphicsGridView::moved() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml")); qApp->processEvents(); QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid"); @@ -580,7 +580,6 @@ void tst_QmlGraphicsGridView::currentIndex() QString filename(SRCDIR "/data/gridview-initCurrent.qml"); canvas->setSource(QUrl::fromLocalFile(filename)); - canvas->execute(); qApp->processEvents(); QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid"); @@ -690,7 +689,7 @@ void tst_QmlGraphicsGridView::currentIndex() void tst_QmlGraphicsGridView::changeFlow() { - QmlView *canvas = createView(SRCDIR "/data/gridview.qml"); + QmlView *canvas = createView(); TestModel model; for (int i = 0; i < 30; i++) @@ -700,7 +699,7 @@ void tst_QmlGraphicsGridView::changeFlow() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml")); qApp->processEvents(); QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid"); @@ -795,7 +794,7 @@ void tst_QmlGraphicsGridView::properties() void tst_QmlGraphicsGridView::positionViewAtIndex() { - QmlView *canvas = createView(SRCDIR "/data/gridview.qml"); + QmlView *canvas = createView(); TestModel model; for (int i = 0; i < 40; i++) @@ -805,7 +804,7 @@ void tst_QmlGraphicsGridView::positionViewAtIndex() ctxt->setContextProperty("testModel", &model); ctxt->setContextProperty("testTopToBottom", QVariant(false)); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/gridview.qml")); qApp->processEvents(); QmlGraphicsGridView *gridview = findItem<QmlGraphicsGridView>(canvas->rootObject(), "grid"); @@ -883,13 +882,11 @@ void tst_QmlGraphicsGridView::positionViewAtIndex() delete canvas; } -QmlView *tst_QmlGraphicsGridView::createView(const QString &filename) +QmlView *tst_QmlGraphicsGridView::createView() { QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - canvas->setSource(QUrl::fromLocalFile(filename)); - return canvas; } diff --git a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp index 820a6de..1bface4 100644 --- a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp +++ b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp @@ -112,14 +112,12 @@ void tst_QmlGraphicsItem::keys() QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keys.qml")); - KeysTestObject *testObject = new KeysTestObject; canvas->rootContext()->setContextProperty("keysTestObject", testObject); canvas->rootContext()->setContextProperty("enableKeyHanding", QVariant(true)); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keys.qml")); canvas->show(); qApp->processEvents(); @@ -195,7 +193,6 @@ void tst_QmlGraphicsItem::keyNavigation() canvas->setFixedSize(240,320); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigation.qml")); - canvas->execute(); canvas->show(); qApp->processEvents(); diff --git a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml index 99b3db6..1c1b3f8 100644 --- a/tests/auto/declarative/qmlgraphicslistview/data/listview.qml +++ b/tests/auto/declarative/qmlgraphicslistview/data/listview.qml @@ -88,7 +88,7 @@ Rectangle { ScriptAction { script: console.log("Fix PropertyAction with attached properties") } /* PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } - NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing: "easeInOutQuad" } + NumberAnimation { target: wrapper; property: "scale"; to: 0; duration: 250; easing.type: "InOutQuad" } PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: false } */ } diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp index 13ed41d..cf96ad5 100644 --- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp +++ b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp @@ -88,7 +88,7 @@ private: template <class T> void removed(bool animated); template <class T> void moved(); template <class T> void clear(); - QmlView *createView(const QString &filename); + QmlView *createView(); template<typename T> T *findItem(QGraphicsObject *parent, const QString &id, int index=-1); template<typename T> @@ -300,7 +300,7 @@ tst_QmlGraphicsListView::tst_QmlGraphicsListView() template <class T> void tst_QmlGraphicsListView::items() { - QmlView *canvas = createView(SRCDIR "/data/listview.qml"); + QmlView *canvas = createView(); T model; model.addItem("Fred", "12345"); @@ -313,7 +313,7 @@ void tst_QmlGraphicsListView::items() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); qApp->processEvents(); QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); @@ -380,7 +380,7 @@ void tst_QmlGraphicsListView::items() template <class T> void tst_QmlGraphicsListView::changed() { - QmlView *canvas = createView(SRCDIR "/data/listview.qml"); + QmlView *canvas = createView(); T model; model.addItem("Fred", "12345"); @@ -393,7 +393,7 @@ void tst_QmlGraphicsListView::changed() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); qApp->processEvents(); QmlGraphicsFlickable *listview = findItem<QmlGraphicsFlickable>(canvas->rootObject(), "list"); @@ -416,7 +416,7 @@ void tst_QmlGraphicsListView::changed() template <class T> void tst_QmlGraphicsListView::inserted() { - QmlView *canvas = createView(SRCDIR "/data/listview.qml"); + QmlView *canvas = createView(); T model; model.addItem("Fred", "12345"); @@ -429,7 +429,7 @@ void tst_QmlGraphicsListView::inserted() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); qApp->processEvents(); QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); @@ -509,7 +509,7 @@ void tst_QmlGraphicsListView::inserted() template <class T> void tst_QmlGraphicsListView::removed(bool animated) { - QmlView *canvas = createView(SRCDIR "/data/listview.qml"); + QmlView *canvas = createView(); T model; for (int i = 0; i < 30; i++) @@ -522,7 +522,7 @@ void tst_QmlGraphicsListView::removed(bool animated) testObject->setAnimate(animated); ctxt->setContextProperty("testObject", testObject); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); qApp->processEvents(); QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); @@ -652,7 +652,7 @@ void tst_QmlGraphicsListView::removed(bool animated) template <class T> void tst_QmlGraphicsListView::clear() { - QmlView *canvas = createView(SRCDIR "/data/listview.qml"); + QmlView *canvas = createView(); T model; for (int i = 0; i < 30; i++) @@ -664,7 +664,7 @@ void tst_QmlGraphicsListView::clear() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); qApp->processEvents(); QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); @@ -689,7 +689,7 @@ void tst_QmlGraphicsListView::clear() template <class T> void tst_QmlGraphicsListView::moved() { - QmlView *canvas = createView(SRCDIR "/data/listview.qml"); + QmlView *canvas = createView(); T model; for (int i = 0; i < 30; i++) @@ -701,7 +701,7 @@ void tst_QmlGraphicsListView::moved() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); qApp->processEvents(); QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); @@ -785,7 +785,7 @@ void tst_QmlGraphicsListView::moved() void tst_QmlGraphicsListView::enforceRange() { - QmlView *canvas = createView(SRCDIR "/data/listview-enforcerange.qml"); + QmlView *canvas = createView(); TestModel model; for (int i = 0; i < 30; i++) @@ -794,7 +794,7 @@ void tst_QmlGraphicsListView::enforceRange() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-enforcerange.qml")); qApp->processEvents(); QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); @@ -830,7 +830,7 @@ void tst_QmlGraphicsListView::enforceRange() void tst_QmlGraphicsListView::spacing() { - QmlView *canvas = createView(SRCDIR "/data/listview.qml"); + QmlView *canvas = createView(); TestModel model; for (int i = 0; i < 30; i++) @@ -842,7 +842,7 @@ void tst_QmlGraphicsListView::spacing() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); qApp->processEvents(); QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); @@ -888,7 +888,7 @@ void tst_QmlGraphicsListView::spacing() void tst_QmlGraphicsListView::sections() { - QmlView *canvas = createView(SRCDIR "/data/listview-sections.qml"); + QmlView *canvas = createView(); TestModel model; for (int i = 0; i < 30; i++) @@ -897,7 +897,7 @@ void tst_QmlGraphicsListView::sections() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview-sections.qml")); qApp->processEvents(); QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); @@ -975,7 +975,6 @@ void tst_QmlGraphicsListView::currentIndex() QString filename(SRCDIR "/data/listview-initCurrent.qml"); canvas->setSource(QUrl::fromLocalFile(filename)); - canvas->execute(); qApp->processEvents(); QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); @@ -1055,9 +1054,9 @@ void tst_QmlGraphicsListView::currentIndex() void tst_QmlGraphicsListView::itemList() { - QmlView *canvas = createView(SRCDIR "/data/itemlist.qml"); + QmlView *canvas = createView(); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/itemlist.qml")); qApp->processEvents(); QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "view"); @@ -1096,7 +1095,7 @@ void tst_QmlGraphicsListView::itemList() void tst_QmlGraphicsListView::cacheBuffer() { - QmlView *canvas = createView(SRCDIR "/data/listview.qml"); + QmlView *canvas = createView(); TestModel model; for (int i = 0; i < 30; i++) @@ -1108,7 +1107,7 @@ void tst_QmlGraphicsListView::cacheBuffer() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); qApp->processEvents(); QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); @@ -1148,7 +1147,7 @@ void tst_QmlGraphicsListView::cacheBuffer() void tst_QmlGraphicsListView::positionViewAtIndex() { - QmlView *canvas = createView(SRCDIR "/data/listview.qml"); + QmlView *canvas = createView(); TestModel model; for (int i = 0; i < 40; i++) @@ -1160,7 +1159,7 @@ void tst_QmlGraphicsListView::positionViewAtIndex() TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/listview.qml")); qApp->processEvents(); QmlGraphicsListView *listview = findItem<QmlGraphicsListView>(canvas->rootObject(), "list"); @@ -1295,13 +1294,11 @@ void tst_QmlGraphicsListView::qAbstractItemModel_clear() clear<TestModel2>(); } -QmlView *tst_QmlGraphicsListView::createView(const QString &filename) +QmlView *tst_QmlGraphicsListView::createView() { QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - canvas->setSource(QUrl::fromLocalFile(filename)); - return canvas; } @@ -1322,7 +1319,6 @@ T *tst_QmlGraphicsListView::findItem(QGraphicsObject *parent, const QString &obj if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { if (index != -1) { QmlExpression e(qmlContext(item), "index", item); - e.setTrackChange(false); if (e.value().toInt() == index) return static_cast<T*>(item); } else { diff --git a/tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp b/tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp index 869a7bd..22a12a9 100644 --- a/tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp +++ b/tests/auto/declarative/qmlgraphicsmousearea/tst_qmlgraphicsmousearea.cpp @@ -56,7 +56,6 @@ private: void tst_QmlGraphicsMouseArea::dragProperties() { QmlView *canvas = createView(SRCDIR "/data/dragproperties.qml"); - canvas->execute(); canvas->show(); canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); diff --git a/tests/auto/declarative/qmlgraphicsparticles/data/particlemotion.qml b/tests/auto/declarative/qmlgraphicsparticles/data/particlemotion.qml new file mode 100644 index 0000000..ace61fe --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsparticles/data/particlemotion.qml @@ -0,0 +1,33 @@ +import Qt 4.6 +Rectangle { + width: 240 + height: 320 + color: "black" + Particles { + objectName: "particles" + anchors.fill: parent + width: 1 + height: 1 + source: "particle.png" + lifeSpan: 5000 + count: 200 + angle: 270 + angleDeviation: 45 + velocity: 50 + velocityDeviation: 30 + ParticleMotionGravity { + objectName: "motionGravity" + yattractor: 1000 + xattractor: 0 + acceleration: 25 + } + } + resources: [ + ParticleMotionWander { + objectName: "motionWander" + xvariance: 30 + yvariance: 30 + pace: 100 + } + ] +}
\ No newline at end of file diff --git a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp index a5c0b78..9436772 100644 --- a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp +++ b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include <QtTest/QtTest> +#include <QtTest/QSignalSpy> #include <qmlview.h> #include <private/qmlgraphicsparticles_p.h> @@ -50,6 +51,8 @@ public: private slots: void properties(); + void motionGravity(); + void motionWander(); void runs(); private: QmlView *createView(const QString &filename); @@ -98,6 +101,91 @@ void tst_QmlGraphicsParticles::properties() QCOMPARE(particles->emissionRate(), 12); } +void tst_QmlGraphicsParticles::motionGravity() +{ + QmlView *canvas = createView(SRCDIR "/data/particlemotion.qml"); + QVERIFY(canvas->rootObject()); + QmlGraphicsParticles* particles = canvas->rootObject()->findChild<QmlGraphicsParticles*>("particles"); + QVERIFY(particles); + + QmlGraphicsParticleMotionGravity* motionGravity = canvas->rootObject()->findChild<QmlGraphicsParticleMotionGravity*>("motionGravity"); + QCOMPARE(particles->motion(), motionGravity); + + QSignalSpy xattractorSpy(motionGravity, SIGNAL(xattractorChanged())); + QSignalSpy yattractorSpy(motionGravity, SIGNAL(yattractorChanged())); + QSignalSpy accelerationSpy(motionGravity, SIGNAL(accelerationChanged())); + + QCOMPARE(motionGravity->xAttractor(), 0.0); + QCOMPARE(motionGravity->yAttractor(), 1000.0); + QCOMPARE(motionGravity->acceleration(), 25.0); + + motionGravity->setXAttractor(20.0); + motionGravity->setYAttractor(10.0); + motionGravity->setAcceleration(10.0); + + QCOMPARE(motionGravity->xAttractor(), 20.0); + QCOMPARE(motionGravity->yAttractor(), 10.0); + QCOMPARE(motionGravity->acceleration(), 10.0); + + QCOMPARE(xattractorSpy.count(), 1); + QCOMPARE(yattractorSpy.count(), 1); + QCOMPARE(accelerationSpy.count(), 1); + + motionGravity->setXAttractor(20.0); + motionGravity->setYAttractor(10.0); + motionGravity->setAcceleration(10.0); + + QCOMPARE(xattractorSpy.count(), 1); + QCOMPARE(yattractorSpy.count(), 1); + QCOMPARE(accelerationSpy.count(), 1); +} + +void tst_QmlGraphicsParticles::motionWander() +{ + QmlView *canvas = createView(SRCDIR "/data/particlemotion.qml"); + QVERIFY(canvas->rootObject()); + QmlGraphicsParticles* particles = canvas->rootObject()->findChild<QmlGraphicsParticles*>("particles"); + QVERIFY(particles); + + QSignalSpy motionSpy(particles, SIGNAL(motionChanged())); + QmlGraphicsParticleMotionWander* motionWander = canvas->rootObject()->findChild<QmlGraphicsParticleMotionWander*>("motionWander"); + + particles->setMotion(motionWander); + QCOMPARE(particles->motion(),motionWander); + QCOMPARE(motionSpy.count(), 1); + + particles->setMotion(motionWander); + QCOMPARE(motionSpy.count(), 1); + + QSignalSpy xvarianceSpy(motionWander, SIGNAL(xvarianceChanged())); + QSignalSpy yvarianceSpy(motionWander, SIGNAL(yvarianceChanged())); + QSignalSpy paceSpy(motionWander, SIGNAL(paceChanged())); + + QCOMPARE(motionWander->xVariance(), 30.0); + QCOMPARE(motionWander->yVariance(), 30.0); + QCOMPARE(motionWander->pace(), 100.0); + + motionWander->setXVariance(20.0); + motionWander->setYVariance(10.0); + motionWander->setPace(10.0); + + QCOMPARE(motionWander->xVariance(), 20.0); + QCOMPARE(motionWander->yVariance(), 10.0); + QCOMPARE(motionWander->pace(), 10.0); + + QCOMPARE(xvarianceSpy.count(), 1); + QCOMPARE(yvarianceSpy.count(), 1); + QCOMPARE(paceSpy.count(), 1); + + motionWander->setXVariance(20.0); + motionWander->setYVariance(10.0); + motionWander->setPace(10.0); + + QCOMPARE(xvarianceSpy.count(), 1); + QCOMPARE(yvarianceSpy.count(), 1); + QCOMPARE(paceSpy.count(), 1); +} + void tst_QmlGraphicsParticles::runs() { QmlView *canvas = createView(SRCDIR "/data/particles.qml"); @@ -113,7 +201,6 @@ QmlView *tst_QmlGraphicsParticles::createView(const QString &filename) canvas->setFixedSize(240,320); canvas->setSource(QUrl::fromLocalFile(filename)); - canvas->execute(); return canvas; } diff --git a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp index b986a64..b57142e 100644 --- a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp +++ b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp @@ -69,7 +69,7 @@ private slots: void pathMoved(); private: - QmlView *createView(const QString &filename); + QmlView *createView(); template<typename T> T *findItem(QGraphicsObject *parent, const QString &objectName, int index=-1); template<typename T> @@ -191,7 +191,7 @@ void tst_QmlGraphicsPathView::initValues() void tst_QmlGraphicsPathView::items() { - QmlView *canvas = createView(SRCDIR "/data/pathview.qml"); + QmlView *canvas = createView(); TestModel model; model.addItem("Fred", "12345"); @@ -201,7 +201,7 @@ void tst_QmlGraphicsPathView::items() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview.qml")); qApp->processEvents(); QmlGraphicsPathView *pathview = findItem<QmlGraphicsPathView>(canvas->rootObject(), "view"); @@ -304,7 +304,7 @@ void tst_QmlGraphicsPathView::path() void tst_QmlGraphicsPathView::dataModel() { - QmlView *canvas = createView(SRCDIR "/data/datamodel.qml"); + QmlView *canvas = createView(); QmlContext *ctxt = canvas->rootContext(); TestObject *testObject = new TestObject; @@ -323,7 +323,7 @@ void tst_QmlGraphicsPathView::dataModel() ctxt->setContextProperty("testData", &model); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/datamodel.qml")); qApp->processEvents(); QmlGraphicsPathView *pathview = qobject_cast<QmlGraphicsPathView*>(canvas->rootObject()); @@ -384,7 +384,7 @@ void tst_QmlGraphicsPathView::dataModel() void tst_QmlGraphicsPathView::pathMoved() { - QmlView *canvas = createView(SRCDIR "/data/pathview.qml"); + QmlView *canvas = createView(); TestModel model; model.addItem("Ben", "12345"); @@ -395,7 +395,7 @@ void tst_QmlGraphicsPathView::pathMoved() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testModel", &model); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/pathview.qml")); qApp->processEvents(); QmlGraphicsPathView *pathview = findItem<QmlGraphicsPathView>(canvas->rootObject(), "view"); @@ -425,13 +425,11 @@ void tst_QmlGraphicsPathView::pathMoved() delete canvas; } -QmlView *tst_QmlGraphicsPathView::createView(const QString &filename) +QmlView *tst_QmlGraphicsPathView::createView() { QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - canvas->setSource(QUrl::fromLocalFile(filename)); - return canvas; } @@ -452,7 +450,6 @@ T *tst_QmlGraphicsPathView::findItem(QGraphicsObject *parent, const QString &obj if (mo.cast(item) && (objectName.isEmpty() || item->objectName() == objectName)) { if (index != -1) { QmlExpression e(qmlContext(item), "index", item); - e.setTrackChange(false); if (e.value().toInt() == index) return static_cast<T*>(item); } else { diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/propertychanges.qml b/tests/auto/declarative/qmlgraphicspositioners/data/propertychanges.qml new file mode 100644 index 0000000..c3dc7bf --- /dev/null +++ b/tests/auto/declarative/qmlgraphicspositioners/data/propertychanges.qml @@ -0,0 +1,39 @@ +import Qt 4.6 + +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: "easeOutInCubic" + } + }, + Transition { + id: columnTransition + objectName: "columnTransition" + NumberAnimation { + properties: "x,y"; + easing: "easeOutInCubic" + } + } + ] +} diff --git a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp index 21c0efc..27db5fe 100644 --- a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp +++ b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp @@ -42,6 +42,8 @@ #include <private/qlistmodelinterface_p.h> #include <qmlview.h> #include <private/qmlgraphicsrectangle_p.h> +#include <private/qmlgraphicspositioners_p.h> +#include <private/qmltransition_p.h> #include <qmlexpression.h> #include "../../../shared/util.h" @@ -61,7 +63,7 @@ private slots: void test_grid(); void test_grid_spacing(); void test_grid_animated(); - + void test_propertychanges(); void test_repeater(); private: QmlView *createView(const QString &filename); @@ -75,8 +77,6 @@ void tst_QmlGraphicsPositioners::test_horizontal() { QmlView *canvas = createView(SRCDIR "/data/horizontal.qml"); - canvas->execute(); - QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); @@ -98,8 +98,6 @@ void tst_QmlGraphicsPositioners::test_horizontal_spacing() { QmlView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml"); - canvas->execute(); - QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); @@ -121,8 +119,6 @@ void tst_QmlGraphicsPositioners::test_horizontal_animated() { QmlView *canvas = createView(SRCDIR "/data/horizontal-animated.qml"); - canvas->execute(); - QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); @@ -163,8 +159,6 @@ void tst_QmlGraphicsPositioners::test_vertical() { QmlView *canvas = createView(SRCDIR "/data/vertical.qml"); - canvas->execute(); - QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); @@ -186,8 +180,6 @@ void tst_QmlGraphicsPositioners::test_vertical_spacing() { QmlView *canvas = createView(SRCDIR "/data/vertical-spacing.qml"); - canvas->execute(); - QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); @@ -209,8 +201,6 @@ void tst_QmlGraphicsPositioners::test_vertical_animated() { QmlView *canvas = createView(SRCDIR "/data/vertical-animated.qml"); - canvas->execute(); - //Note that they animate in QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); @@ -251,8 +241,6 @@ void tst_QmlGraphicsPositioners::test_grid() { QmlView *canvas = createView(SRCDIR "/data/grid.qml"); - canvas->execute(); - QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two"); @@ -280,8 +268,6 @@ void tst_QmlGraphicsPositioners::test_grid_spacing() { QmlView *canvas = createView(SRCDIR "/data/grid-spacing.qml"); - canvas->execute(); - QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); QmlGraphicsRectangle *two = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("two"); @@ -308,7 +294,6 @@ void tst_QmlGraphicsPositioners::test_grid_spacing() void tst_QmlGraphicsPositioners::test_grid_animated() { QmlView *canvas = createView(SRCDIR "/data/grid-animated.qml"); - canvas->execute(); //Note that all animate in QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); @@ -378,13 +363,66 @@ void tst_QmlGraphicsPositioners::test_grid_animated() QTRY_COMPARE(five->y(), 50.0); } +void tst_QmlGraphicsPositioners::test_propertychanges() +{ + QmlView *canvas = createView("data/propertychanges.qml"); + + QmlGraphicsGrid *grid = qobject_cast<QmlGraphicsGrid*>(canvas->rootObject()); + QmlTransition *rowTransition = canvas->rootObject()->findChild<QmlTransition*>("rowTransition"); + QmlTransition *columnTransition = canvas->rootObject()->findChild<QmlTransition*>("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); +} void tst_QmlGraphicsPositioners::test_repeater() { QmlView *canvas = createView(SRCDIR "/data/repeater.qml"); - canvas->execute(); - QmlGraphicsRectangle *one = canvas->rootObject()->findChild<QmlGraphicsRectangle*>("one"); QVERIFY(one != 0); diff --git a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp index c971840..9f3ff45 100644 --- a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp +++ b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp @@ -68,7 +68,7 @@ private slots: void properties(); private: - QmlView *createView(const QString &filename); + QmlView *createView(); template<typename T> T *findItem(QGraphicsObject *parent, const QString &id); }; @@ -164,14 +164,14 @@ tst_QmlGraphicsRepeater::tst_QmlGraphicsRepeater() void tst_QmlGraphicsRepeater::numberModel() { - QmlView *canvas = createView(SRCDIR "/data/intmodel.qml"); + QmlView *canvas = createView(); QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testData", 5); TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/intmodel.qml")); qApp->processEvents(); QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater"); @@ -186,7 +186,7 @@ void tst_QmlGraphicsRepeater::numberModel() void tst_QmlGraphicsRepeater::objectList() { - QmlView *canvas = createView(SRCDIR "/data/objlist.qml"); + QmlView *canvas = createView(); QObjectList data; for(int i=0; i<100; i++){ @@ -197,7 +197,7 @@ void tst_QmlGraphicsRepeater::objectList() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testData", QVariant::fromValue(data)); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/objlist.qml")); qApp->processEvents(); QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater"); @@ -213,7 +213,7 @@ elements to test this. */ void tst_QmlGraphicsRepeater::stringList() { - QmlView *canvas = createView(SRCDIR "/data/repeater.qml"); + QmlView *canvas = createView(); QStringList data; data << "One"; @@ -224,7 +224,7 @@ void tst_QmlGraphicsRepeater::stringList() QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("testData", data); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater.qml")); qApp->processEvents(); QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater"); @@ -265,7 +265,7 @@ void tst_QmlGraphicsRepeater::stringList() void tst_QmlGraphicsRepeater::dataModel() { - QmlView *canvas = createView(SRCDIR "/data/repeater2.qml"); + QmlView *canvas = createView(); QmlContext *ctxt = canvas->rootContext(); TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); @@ -277,7 +277,7 @@ void tst_QmlGraphicsRepeater::dataModel() ctxt->setContextProperty("testData", &testModel); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/repeater2.qml")); qApp->processEvents(); QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater"); @@ -297,12 +297,12 @@ void tst_QmlGraphicsRepeater::dataModel() void tst_QmlGraphicsRepeater::itemModel() { - QmlView *canvas = createView(SRCDIR "/data/itemlist.qml"); + QmlView *canvas = createView(); QmlContext *ctxt = canvas->rootContext(); TestObject *testObject = new TestObject; ctxt->setContextProperty("testObject", testObject); - canvas->execute(); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/itemlist.qml")); qApp->processEvents(); QmlGraphicsRepeater *repeater = findItem<QmlGraphicsRepeater>(canvas->rootObject(), "repeater"); @@ -354,13 +354,11 @@ void tst_QmlGraphicsRepeater::properties() QCOMPARE(delegateSpy.count(),1); } -QmlView *tst_QmlGraphicsRepeater::createView(const QString &filename) +QmlView *tst_QmlGraphicsRepeater::createView() { QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - canvas->setSource(QUrl::fromLocalFile(filename)); - return canvas; } diff --git a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp index cc2f929..0d6ac77 100644 --- a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp +++ b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp @@ -604,7 +604,6 @@ void tst_qmlgraphicstextedit::selection() void tst_qmlgraphicstextedit::inputMethodHints() { QmlView *canvas = createView(SRCDIR "/data/inputmethodhints.qml"); - canvas->execute(); canvas->show(); canvas->setFocus(); @@ -619,7 +618,6 @@ void tst_qmlgraphicstextedit::inputMethodHints() void tst_qmlgraphicstextedit::cursorDelegate() { QmlView* view = createView(SRCDIR "/data/cursorTest.qml"); - view->execute(); view->show(); view->setFocus(); QmlGraphicsTextEdit *textEditObject = view->rootObject()->findChild<QmlGraphicsTextEdit*>("textEditObject"); @@ -651,7 +649,6 @@ void tst_qmlgraphicstextedit::delegateLoading() server.serveDirectory(SRCDIR "/data/http"); QmlView* view = new QmlView(0); view->setSource(QUrl("http://localhost:42332/cursorHttpTestPass.qml")); - view->execute(); view->show(); view->setFocus(); QTRY_VERIFY(view->rootObject());//Wait for loading to finish. @@ -665,12 +662,10 @@ void tst_qmlgraphicstextedit::delegateLoading() delegate = view->rootObject()->findChild<QmlGraphicsItem*>("delegateSlow"); QVERIFY(delegate); view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail1.qml")); - view->execute(); view->show(); view->setFocus(); QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail2.qml")); - view->execute(); view->show(); view->setFocus(); QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test @@ -688,7 +683,6 @@ the extent of the text, then they should ignore the keys. void tst_qmlgraphicstextedit::navigation() { QmlView *canvas = createView(SRCDIR "/data/navigation.qml"); - canvas->execute(); canvas->show(); canvas->setFocus(); @@ -711,7 +705,6 @@ void tst_qmlgraphicstextedit::navigation() void tst_qmlgraphicstextedit::readOnly() { QmlView *canvas = createView(SRCDIR "/data/readOnly.qml"); - canvas->execute(); canvas->show(); canvas->setFocus(); diff --git a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp index 8b45fc7..748cf5e 100644 --- a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp +++ b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp @@ -349,7 +349,6 @@ void tst_qmlgraphicstextinput::maxLength() { //QString componentStr = "import Qt 4.6\nTextInput { maximumLength: 10; }"; QmlView *canvas = createView(SRCDIR "/data/maxLength.qml"); - canvas->execute(); canvas->show(); canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); @@ -378,7 +377,6 @@ void tst_qmlgraphicstextinput::masks() //Not a comprehensive test of the possible masks, that's done elsewhere (QLineEdit) //QString componentStr = "import Qt 4.6\nTextInput { inputMask: 'HHHHhhhh'; }"; QmlView *canvas = createView(SRCDIR "/data/masks.qml"); - canvas->execute(); canvas->show(); canvas->setFocus(); QVERIFY(canvas->rootObject() != 0); @@ -403,7 +401,6 @@ void tst_qmlgraphicstextinput::validators() // here to ensure that their exposure to QML is working. QmlView *canvas = createView(SRCDIR "/data/validators.qml"); - canvas->execute(); canvas->show(); canvas->setFocus(); @@ -493,7 +490,6 @@ void tst_qmlgraphicstextinput::validators() void tst_qmlgraphicstextinput::inputMethodHints() { QmlView *canvas = createView(SRCDIR "/data/inputmethodhints.qml"); - canvas->execute(); canvas->show(); canvas->setFocus(); @@ -513,7 +509,6 @@ the extent of the text, then they should ignore the keys. void tst_qmlgraphicstextinput::navigation() { QmlView *canvas = createView(SRCDIR "/data/navigation.qml"); - canvas->execute(); canvas->show(); canvas->setFocus(); @@ -546,7 +541,6 @@ void tst_qmlgraphicstextinput::navigation() void tst_qmlgraphicstextinput::cursorDelegate() { QmlView* view = createView(SRCDIR "/data/cursorTest.qml"); - view->execute(); view->show(); view->setFocus(); QmlGraphicsTextInput *textInputObject = view->rootObject()->findChild<QmlGraphicsTextInput*>("textInputObject"); @@ -574,7 +568,6 @@ void tst_qmlgraphicstextinput::cursorDelegate() void tst_qmlgraphicstextinput::readOnly() { QmlView *canvas = createView(SRCDIR "/data/readOnly.qml"); - canvas->execute(); canvas->show(); canvas->setFocus(); diff --git a/tests/auto/declarative/qmlgraphicswebview/data/propertychanges.qml b/tests/auto/declarative/qmlgraphicswebview/data/propertychanges.qml new file mode 100644 index 0000000..3dd4e51 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicswebview/data/propertychanges.qml @@ -0,0 +1,33 @@ +import Qt 4.6 + +Item { + width: 240 + height: 160 + Grid { + anchors.fill: parent + objectName: "newWindowParent" + id: newWindowParent + } + + Row { + anchors.fill: parent + id: oldWindowParent + objectName: "oldWindowParent" + } + + Loader { + sourceComponent: webViewComponent + } + Component { + id: webViewComponent + WebView { + id: webView + objectName: "webView" + newWindowComponent: webViewComponent + newWindowParent: oldWindowParent + url: "basic.html" + renderingEnabled: true + pressGrabTime: 200 + } + } +}
\ No newline at end of file diff --git a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp index 6672f5b..f4f8a33 100644 --- a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp +++ b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include <qtest.h> +#include <QtTest/QSignalSpy> #include "../../../shared/util.h" #include <QtDeclarative/qmlengine.h> #include <QtDeclarative/qmlcomponent.h> @@ -70,6 +71,10 @@ private slots: void javaScript(); void cleanupTestCase(); void pixelCache(); + void newWindowParent(); + void newWindowComponent(); + void renderingEnabled(); + void pressGrabTime(); private: void checkNoErrors(const QmlComponent& component); @@ -341,6 +346,10 @@ void tst_qmlgraphicswebview::setHtml() QmlGraphicsWebView *wv = qobject_cast<QmlGraphicsWebView*>(component.create()); QVERIFY(wv != 0); QCOMPARE(wv->html(),QString("<html><head></head><body><p>This is a <b>string</b> set on the WebView</p></body></html>")); + + QSignalSpy spy(wv, SIGNAL(htmlChanged())); + wv->setHtml(QString("<html><head><title>Basic</title></head><body><p>text</p></body></html>")); + QCOMPARE(spy.count(),1); } void tst_qmlgraphicswebview::elementAreaAt() @@ -397,6 +406,106 @@ void tst_qmlgraphicswebview::pixelCache() QCOMPARE(wv->pixelsPainted(), expected*3); // repainted } +void tst_qmlgraphicswebview::newWindowParent() +{ + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + checkNoErrors(component); + QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(component.create()); + QmlGraphicsWebView *wv = rootItem->findChild<QmlGraphicsWebView*>("webView"); + QVERIFY(rootItem != 0); + QVERIFY(wv != 0); + QTRY_COMPARE(wv->progress(), 1.0); + + QmlGraphicsItem* oldWindowParent = rootItem->findChild<QmlGraphicsItem*>("oldWindowParent"); + QCOMPARE(wv->newWindowParent(), oldWindowParent); + QSignalSpy newWindowParentSpy(wv, SIGNAL(newWindowParentChanged())); + + QmlGraphicsItem* newWindowParent = rootItem->findChild<QmlGraphicsItem*>("newWindowParent"); + wv->setNewWindowParent(newWindowParent); + QVERIFY(oldWindowParent); + QVERIFY(oldWindowParent->childItems().count() == 0); + QCOMPARE(wv->newWindowParent(), newWindowParent); + QCOMPARE(newWindowParentSpy.count(),1); + + wv->setNewWindowParent(newWindowParent); + QCOMPARE(newWindowParentSpy.count(),1); + + wv->setNewWindowParent(0); + QCOMPARE(newWindowParentSpy.count(),2); +} + +void tst_qmlgraphicswebview::newWindowComponent() +{ + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + checkNoErrors(component); + QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(component.create()); + QmlGraphicsWebView *wv = rootItem->findChild<QmlGraphicsWebView*>("webView"); + QVERIFY(rootItem != 0); + QVERIFY(wv != 0); + QTRY_COMPARE(wv->progress(), 1.0); + + QmlComponent substituteComponent(&engine); + substituteComponent.setData("import Qt 4.6; WebView { objectName: 'newWebView'; url: 'basic.html'; }", QUrl::fromLocalFile("")); + QSignalSpy newWindowComponentSpy(wv, SIGNAL(newWindowComponentChanged())); + + wv->setNewWindowComponent(&substituteComponent); + QCOMPARE(wv->newWindowComponent(), &substituteComponent); + QCOMPARE(newWindowComponentSpy.count(),1); + + wv->setNewWindowComponent(&substituteComponent); + QCOMPARE(newWindowComponentSpy.count(),1); + + wv->setNewWindowComponent(0); + QCOMPARE(newWindowComponentSpy.count(),2); +} + +void tst_qmlgraphicswebview::renderingEnabled() +{ + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + checkNoErrors(component); + QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(component.create()); + QmlGraphicsWebView *wv = rootItem->findChild<QmlGraphicsWebView*>("webView"); + QVERIFY(rootItem != 0); + QVERIFY(wv != 0); + QTRY_COMPARE(wv->progress(), 1.0); + + QVERIFY(wv->renderingEnabled()); + QSignalSpy renderingEnabledSpy(wv, SIGNAL(renderingEnabledChanged())); + + wv->setRenderingEnabled(false); + QVERIFY(!wv->renderingEnabled()); + QCOMPARE(renderingEnabledSpy.count(),1); + + wv->setRenderingEnabled(false); + QCOMPARE(renderingEnabledSpy.count(),1); + + wv->setRenderingEnabled(true); + QCOMPARE(renderingEnabledSpy.count(),2); +} + +void tst_qmlgraphicswebview::pressGrabTime() +{ + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertychanges.qml")); + checkNoErrors(component); + QmlGraphicsItem *rootItem = qobject_cast<QmlGraphicsItem*>(component.create()); + QmlGraphicsWebView *wv = rootItem->findChild<QmlGraphicsWebView*>("webView"); + QVERIFY(rootItem != 0); + QVERIFY(wv != 0); + QTRY_COMPARE(wv->progress(), 1.0); + QCOMPARE(wv->pressGrabTime(), 200); + QSignalSpy pressGrabTimeSpy(wv, SIGNAL(pressGrabTimeChanged())); + + wv->setPressGrabTime(100); + QCOMPARE(wv->pressGrabTime(), 100); + QCOMPARE(pressGrabTimeSpy.count(),1); + + wv->setPressGrabTime(100); + QCOMPARE(pressGrabTimeSpy.count(),1); + + wv->setPressGrabTime(0); + QCOMPARE(pressGrabTimeSpy.count(),2); +} + QTEST_MAIN(tst_qmlgraphicswebview) #include "tst_qmlgraphicswebview.moc" diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp index 4be0800..7bb3e96 100644 --- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp +++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp @@ -43,7 +43,7 @@ #include <QtDeclarative/qmlcomponent.h> #include <QtDeclarative/qmlmetaproperty.h> #include <private/qguard_p.h> -#include <QtDeclarative/qmlbinding.h> +#include <private/qmlbinding_p.h> #include <QtGui/QLineEdit> class MyQmlObject : public QObject diff --git a/tests/auto/declarative/qmlvaluetypes/data/enums.1.qml b/tests/auto/declarative/qmlvaluetypes/data/enums.1.qml new file mode 100644 index 0000000..0eadd50 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/enums.1.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + font.capitalization: "MixedCase" +} + diff --git a/tests/auto/declarative/qmlvaluetypes/data/enums.2.qml b/tests/auto/declarative/qmlvaluetypes/data/enums.2.qml new file mode 100644 index 0000000..81f1c92 --- /dev/null +++ b/tests/auto/declarative/qmlvaluetypes/data/enums.2.qml @@ -0,0 +1,6 @@ +import Test 1.0 + +MyTypeObject { + font.capitalization: if (1) "MixedCase" +} + diff --git a/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp b/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp index 26cf9b0..f28dc51 100644 --- a/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp +++ b/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp @@ -76,6 +76,7 @@ private slots: void bindingVariantCopy(); void scriptVariantCopy(); void cppClasses(); + void enums(); private: QmlEngine engine; @@ -590,6 +591,26 @@ void tst_qmlvaluetypes::cppClasses() CPP_TEST(QmlFontValueType, QFont("Helvetica")); } + +void tst_qmlvaluetypes::enums() +{ + { + QmlComponent component(&engine, TEST_FILE("enums.1.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + QVERIFY(object->font().capitalization() == QFont::MixedCase); + delete object; + } + + { + QmlComponent component(&engine, TEST_FILE("enums.2.qml")); + MyTypeObject *object = qobject_cast<MyTypeObject *>(component.create()); + QVERIFY(object != 0); + QVERIFY(object->font().capitalization() == QFont::MixedCase); + delete object; + } +} + QTEST_MAIN(tst_qmlvaluetypes) #include "tst_qmlvaluetypes.moc" diff --git a/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp b/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp index df1931f..477b661 100644 --- a/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp +++ b/tests/auto/declarative/qmlxmllistmodel/tst_qmlxmllistmodel.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ #include <qtest.h> +#include <QtTest/qsignalspy.h> +#include <QtCore/qtimer.h> #ifdef QTEST_XMLPATTERNS #include <QtDeclarative/qmlengine.h> @@ -46,6 +48,12 @@ #include <private/qmlxmllistmodel_p.h> #include "../../../shared/util.h" +typedef QPair<int, int> QmlXmlListRange; +typedef QList<QVariantList> QmlXmlModelData; + +Q_DECLARE_METATYPE(QList<QmlXmlListRange>) +Q_DECLARE_METATYPE(QmlXmlModelData) + class tst_qmlxmllistmodel : public QObject { @@ -61,8 +69,47 @@ private slots: void roles(); void roleErrors(); void uniqueRoleNames(); + void useKeys(); + void useKeys_data(); + void noKeysValueChanges(); + void keysChanged(); private: + QString makeItemXmlAndData(const QString &data, QmlXmlModelData *modelData = 0) const + { + if (modelData) + modelData->clear(); + QString xml; + + if (!data.isEmpty()) { + QStringList items = data.split(";"); + foreach(const QString &item, items) { + QVariantList variants; + xml += QLatin1String("<item>"); + QStringList fields = item.split(","); + foreach(const QString &field, fields) { + QStringList values = field.split("="); + Q_ASSERT(values.count() == 2); + xml += QString("<%1>%2</%1>").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("</item>"); + if (modelData) + modelData->append(variants); + } + } + + QString decl = "<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?>"; + return decl + QLatin1String("<data>") + xml + QLatin1String("</data>"); + } + QmlEngine engine; }; @@ -194,6 +241,213 @@ void tst_qmlxmllistmodel::uniqueRoleNames() delete listModel; } +void tst_qmlxmllistmodel::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(QmlXmlModelData, newData); + QFETCH(QList<QmlXmlListRange>, insertRanges); + QFETCH(QList<QmlXmlListRange>, removeRanges); + + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml")); + QmlXmlListModel *model = qobject_cast<QmlXmlListModel*>(component.create()); + QVERIFY(model != 0); + + model->setXml(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->setXml(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<int> roles = model->roles(); + for (int i=0; i<model->count(); i++) { + for (int j=0; j<roles.count(); j++) + QCOMPARE(model->data(i, roles[j]), newData[i][j]); + } + + QCOMPARE(spyInsert.count(), insertRanges.count()); + for (int i=0; i<spyInsert.count(); i++) { + QCOMPARE(spyInsert[i][0].toInt(), insertRanges[i].first); + QCOMPARE(spyInsert[i][1].toInt(), insertRanges[i].second); + } + + QCOMPARE(spyRemove.count(), removeRanges.count()); + for (int i=0; i<spyRemove.count(); i++) { + QCOMPARE(spyRemove[i][0].toInt(), removeRanges[i].first); + QCOMPARE(spyRemove[i][1].toInt(), removeRanges[i].second); + } +} + +void tst_qmlxmllistmodel::useKeys_data() +{ + QTest::addColumn<QString>("oldXml"); + QTest::addColumn<int>("oldCount"); + QTest::addColumn<QString>("newXml"); + QTest::addColumn<QmlXmlModelData>("newData"); + QTest::addColumn<QList<QmlXmlListRange> >("insertRanges"); + QTest::addColumn<QList<QmlXmlListRange> >("removeRanges"); + + QmlXmlModelData 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<QmlXmlListRange>() << qMakePair(1, 1)) + << QList<QmlXmlListRange>(); + + 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<QmlXmlListRange>() << qMakePair(1, 2)) + << QList<QmlXmlListRange>(); + + 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<QmlXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2)) + << QList<QmlXmlListRange>(); + + 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<QmlXmlListRange>() << qMakePair(1, 2)) + << QList<QmlXmlListRange>(); + + 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<QmlXmlListRange>() + << (QList<QmlXmlListRange>() << 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<QmlXmlListRange>() + << (QList<QmlXmlListRange>() << 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<QmlXmlListRange>() + << (QList<QmlXmlListRange>() << 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<QmlXmlListRange>() + << (QList<QmlXmlListRange>() << 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<QmlXmlListRange>() << qMakePair(0, 1)) + << (QList<QmlXmlListRange>() << qMakePair(0, 1)); + + QTest::newRow("add and remove simultaneously") + << 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<QmlXmlListRange>() << qMakePair(1, 1)) + << (QList<QmlXmlListRange>() << qMakePair(0, 1) << qMakePair(2,2)); +} + +void tst_qmlxmllistmodel::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. + + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml")); + QmlXmlListModel *model = qobject_cast<QmlXmlListModel*>(component.create()); + QVERIFY(model != 0); + + QString xml; + + xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics"); + model->setXml(xml); + QTRY_COMPARE(model->count(), 2); + + 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->setXml(xml); + + // wait for the new xml data to be set, and verify no signals were emitted + for (int i=0; i<50; i++) { + QTest::qWait(100); + if (model->data(0, model->roles()[2]).toString() != QLatin1String("AussieRules")) + break; + } + 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); +} + +void tst_qmlxmllistmodel::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). + + QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/roleKeys.qml")); + QmlXmlListModel *model = qobject_cast<QmlXmlListModel*>(component.create()); + QVERIFY(model != 0); + + QString xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics"); + model->setXml(xml); + QTRY_COMPARE(model->count(), 2); + + 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->setXml(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); +} + QTEST_MAIN(tst_qmlxmllistmodel) #include "tst_qmlxmllistmodel.moc" diff --git a/tests/auto/declarative/visual/Package_Views/packageviews.qml b/tests/auto/declarative/visual/Package_Views/packageviews.qml index b577e45..cf3f9f7 100644 --- a/tests/auto/declarative/visual/Package_Views/packageviews.qml +++ b/tests/auto/declarative/visual/Package_Views/packageviews.qml @@ -64,7 +64,7 @@ Rectangle { from: "*"; to: "*" SequentialAnimation { ParentAction{} - NumberAnimation { properties: "x,y,width"; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,width"; easing.type: "InOutQuad" } } } ] diff --git a/tests/auto/declarative/visual/animation/easing/easing.qml b/tests/auto/declarative/visual/animation/easing/easing.qml index 9c814eb..4248d88 100644 --- a/tests/auto/declarative/visual/animation/easing/easing.qml +++ b/tests/auto/declarative/visual/animation/easing/easing.qml @@ -9,127 +9,127 @@ Rectangle { ListModel { id: easingtypes ListElement { - type: "easeLinear" + type: "Linear" } ListElement { - type: "easeInQuad" + type: "InQuad" } ListElement { - type: "easeOutQuad" + type: "OutQuad" } ListElement { - type: "easeInOutQuad" + type: "InOutQuad" } ListElement { - type: "easeOutInQuad" + type: "OutInQuad" } ListElement { - type: "easeInCubic" + type: "InCubic" } ListElement { - type: "easeOutCubic" + type: "OutCubic" } ListElement { - type: "easeInOutCubic" + type: "InOutCubic" } ListElement { - type: "easeOutInCubic" + type: "OutInCubic" } ListElement { - type: "easeInQuart" + type: "InQuart" } ListElement { - type: "easeOutQuart" + type: "OutQuart" } ListElement { - type: "easeInOutQuart" + type: "InOutQuart" } ListElement { - type: "easeOutInQuart" + type: "OutInQuart" } ListElement { - type: "easeInQuint" + type: "InQuint" } ListElement { - type: "easeOutQuint" + type: "OutQuint" } ListElement { - type: "easeInOutQuint" + type: "InOutQuint" } ListElement { - type: "easeOutInQuint" + type: "OutInQuint" } ListElement { - type: "easeInSine" + type: "InSine" } ListElement { - type: "easeOutSine" + type: "OutSine" } ListElement { - type: "easeInOutSine" + type: "InOutSine" } ListElement { - type: "easeOutInSine" + type: "OutInSine" } ListElement { - type: "easeInExpo" + type: "InExpo" } ListElement { - type: "easeOutExpo" + type: "OutExpo" } ListElement { - type: "easeInOutExpo" + type: "InOutExpo" } ListElement { - type: "easeOutInExpo" + type: "OutInExpo" } ListElement { - type: "easeInCirc" + type: "InCirc" } ListElement { - type: "easeOutCirc" + type: "OutCirc" } ListElement { - type: "easeInOutCirc" + type: "InOutCirc" } ListElement { - type: "easeOutInCirc" + type: "OutInCirc" } ListElement { - type: "easeInElastic" + type: "InElastic" } ListElement { - type: "easeOutElastic" + type: "OutElastic" } ListElement { - type: "easeInOutElastic" + type: "InOutElastic" } ListElement { - type: "easeOutInElastic" + type: "OutInElastic" } ListElement { - type: "easeInBack" + type: "InBack" } ListElement { - type: "easeOutBack" + type: "OutBack" } ListElement { - type: "easeInOutBack" + type: "InOutBack" } ListElement { - type: "easeOutInBack" + type: "OutInBack" } ListElement { - type: "easeOutBounce" + type: "OutBounce" } ListElement { - type: "easeInBounce" + type: "InBounce" } ListElement { - type: "easeInOutBounce" + type: "InOutBounce" } ListElement { - type: "easeOutInBounce" + type: "OutInBounce" } } ] @@ -177,7 +177,7 @@ Rectangle { reversible: true NumberAnimation { properties: "x" - easing: type + easing.type: type duration: 1000 } } diff --git a/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml b/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml index f2e065d..24ca76b 100644 --- a/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml +++ b/tests/auto/declarative/visual/animation/pauseAnimation/pauseAnimation.qml @@ -14,11 +14,11 @@ Rectangle { repeat: true NumberAnimation { to: 0; duration: 500 - easing: "easeInOutQuad" + easing.type: "InOutQuad" } NumberAnimation { to: 200-img.height - easing: "easeOutBounce" + easing.type: "OutBounce" duration: 2000 } PauseAnimation { diff --git a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml index 593f495..e18e770 100644 --- a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml +++ b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml @@ -28,7 +28,7 @@ Rectangle { SequentialAnimation { ColorAnimation {} PropertyAction { properties: "x" } - NumberAnimation { properties: "y"; easing: "InOutQuad" } + NumberAnimation { properties: "y"; easing.type: "InOutQuad" } } } } diff --git a/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml b/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml index 30d587a..ef4ed76 100644 --- a/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml +++ b/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml @@ -27,9 +27,9 @@ Rectangle { transitions: Transition { SequentialAnimation { - NumberAnimation { properties: "x"; easing: "InOutQuad" } + NumberAnimation { properties: "x"; easing.type: "InOutQuad" } ScriptAction { stateChangeScriptName: "setColor" } - NumberAnimation { properties: "y"; easing: "InOutQuad" } + NumberAnimation { properties: "y"; easing.type: "InOutQuad" } } } } diff --git a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/MyBorderImage.qml b/tests/auto/declarative/visual/qmlgraphicsborderimage/content/MyBorderImage.qml index eb1ec00..e268ce7 100644 --- a/tests/auto/declarative/visual/qmlgraphicsborderimage/content/MyBorderImage.qml +++ b/tests/auto/declarative/visual/qmlgraphicsborderimage/content/MyBorderImage.qml @@ -20,14 +20,14 @@ Item { width: SequentialAnimation { repeat: true - NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing: "easeInOutQuad"} - NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing: "easeInOutQuad" } + NumberAnimation { from: container.minWidth; to: container.maxWidth; duration: 2000; easing.type: "InOutQuad"} + NumberAnimation { from: container.maxWidth; to: container.minWidth; duration: 2000; easing.type: "InOutQuad" } } height: SequentialAnimation { repeat: true - NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing: "easeInOutQuad"} - NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing: "easeInOutQuad" } + NumberAnimation { from: container.minHeight; to: container.maxHeight; duration: 2000; easing.type: "InOutQuad"} + NumberAnimation { from: container.maxHeight; to: container.minHeight; duration: 2000; easing.type: "InOutQuad" } } border.top: container.margin diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml b/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml index c33a319..a27aa6e 100644 --- a/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml +++ b/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml @@ -36,7 +36,7 @@ Rectangle { } transitions: Transition { - NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 3000 } + NumberAnimation { easing.type: "InOutQuad"; properties: "angle"; duration: 3000 } } } @@ -64,7 +64,7 @@ Rectangle { } transitions: Transition { - NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 3000 } + NumberAnimation { easing.type: "InOutQuad"; properties: "angle"; duration: 3000 } } } diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml b/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml index e0c5db4..176a5b8 100644 --- a/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml +++ b/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml @@ -11,8 +11,8 @@ import Qt 4.6 Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;} opacity: 1 opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true; - NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"} - NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"} + NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing.type: "InQuad"} + NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing.type: "OutQuad"} } } width: 1; diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml b/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml index 0038664..6a4e7fa 100644 --- a/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml +++ b/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml @@ -11,8 +11,8 @@ import Qt 4.6 Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;} opacity: 1 opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true; - NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"} - NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"} + NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing.type: "InQuad"} + NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing.type: "OutQuad"} } } width: 1; diff --git a/tests/auto/declarative/visual/qmlspringfollow/follow.qml b/tests/auto/declarative/visual/qmlspringfollow/follow.qml index a85a778..62503e4 100644 --- a/tests/auto/declarative/visual/qmlspringfollow/follow.qml +++ b/tests/auto/declarative/visual/qmlspringfollow/follow.qml @@ -11,11 +11,11 @@ Rectangle { repeat: true NumberAnimation { to: 20; duration: 500 - easing: "easeInOutQuad" + easing.type: "InOutQuad" } NumberAnimation { to: 200; duration: 2000 - easing: "easeOutBounce" + easing.type: "OutBounce" } PauseAnimation { duration: 1000 } } diff --git a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp index 12ddff1..abb4014 100644 --- a/tests/auto/qeasingcurve/tst_qeasingcurve.cpp +++ b/tests/auto/qeasingcurve/tst_qeasingcurve.cpp @@ -69,6 +69,10 @@ private slots: void valueForProgress(); void setCustomType(); void operators(); + void dataStreamOperators_data(); + void dataStreamOperators(); + void properties(); + void metaTypes(); protected: }; @@ -505,6 +509,117 @@ void tst_QEasingCurve::operators() QVERIFY(curve2 == curve); } +void tst_QEasingCurve::dataStreamOperators_data() +{ + QTest::addColumn<int>("type"); + QTest::addColumn<qreal>("amplitude"); + QTest::addColumn<qreal>("overshoot"); + QTest::addColumn<qreal>("period"); + QTest::addColumn<QEasingCurve>("easingCurve"); + QTest::newRow("Linear") << int(QEasingCurve::Linear) << -1.0 << -1.0 << -1.0 << QEasingCurve(QEasingCurve::Linear); + QTest::newRow("OutCubic") << int(QEasingCurve::OutCubic) << -1.0 << -1.0 << -1.0 << QEasingCurve(QEasingCurve::OutCubic); + QTest::newRow("InOutSine") << int(QEasingCurve::InOutSine) << -1.0 << -1.0 << -1.0 << QEasingCurve(QEasingCurve::InOutSine); + QEasingCurve inOutElastic(QEasingCurve::InOutElastic); + inOutElastic.setPeriod(1.5); + inOutElastic.setAmplitude(2.0); + QTest::newRow("InOutElastic") << int(QEasingCurve::InOutElastic) << 2.0 << -1.0 << 1.5 << inOutElastic; + QTest::newRow("OutInBack") << int(QEasingCurve::OutInBack) << -1.0 << -1.0 << -1.0 << QEasingCurve(QEasingCurve::OutInBack); + QTest::newRow("OutCurve") << int(QEasingCurve::OutCurve) << -1.0 << -1.0 << -1.0 << QEasingCurve(QEasingCurve::OutCurve); + QEasingCurve inOutBack(QEasingCurve::InOutBack); + inOutBack.setOvershoot(0.5); + QTest::newRow("InOutBack") << int(QEasingCurve::InOutBack) << -1.0 << 0.5 << -1.0 << inOutBack; +} + +void tst_QEasingCurve::dataStreamOperators() +{ + QFETCH(int, type); + QFETCH(qreal, amplitude); + QFETCH(qreal, overshoot); + QFETCH(qreal, period); + QFETCH(QEasingCurve, easingCurve); + + // operator << + QEasingCurve curve; + curve.setType(QEasingCurve::Type(type)); + if (amplitude != -1.0) + curve.setAmplitude(amplitude); + if (overshoot != -1.0) + curve.setOvershoot(overshoot); + if (period != -1.0) + curve.setPeriod(period); + + QVERIFY(easingCurve == curve); + + QByteArray array; + QDataStream out(&array, QIODevice::WriteOnly); + out << curve; + + QDataStream in(array); + QEasingCurve curve2; + in >> curve2; + + QVERIFY(curve2 == curve); +} + +class tst_QEasingProperties : public QObject +{ + Q_OBJECT + Q_PROPERTY(QEasingCurve easing READ easing WRITE setEasing) +public: + tst_QEasingProperties(QObject *parent = 0) : QObject(parent) {} + + QEasingCurve easing() const { return e; } + void setEasing(const QEasingCurve& value) { e = value; } + +private: + QEasingCurve e; +}; + +// Test getting and setting easing properties via the metaobject system. +void tst_QEasingCurve::properties() +{ + tst_QEasingProperties obj; + + QEasingCurve inOutBack(QEasingCurve::InOutBack); + qreal overshoot = 1.5f; + inOutBack.setOvershoot(overshoot); + qreal amplitude = inOutBack.amplitude(); + qreal period = inOutBack.period(); + + obj.setEasing(inOutBack); + + QEasingCurve easing = qVariantValue<QEasingCurve>(obj.property("easing")); + QCOMPARE(easing.type(), QEasingCurve::InOutBack); + QCOMPARE(easing.overshoot(), overshoot); + QCOMPARE(easing.amplitude(), amplitude); + QCOMPARE(easing.period(), period); + + QEasingCurve linear(QEasingCurve::Linear); + overshoot = linear.overshoot(); + amplitude = linear.amplitude(); + period = linear.period(); + + obj.setProperty("easing", + qVariantFromValue(QEasingCurve(QEasingCurve::Linear))); + + easing = qVariantValue<QEasingCurve>(obj.property("easing")); + QCOMPARE(easing.type(), QEasingCurve::Linear); + QCOMPARE(easing.overshoot(), overshoot); + QCOMPARE(easing.amplitude(), amplitude); + QCOMPARE(easing.period(), period); +} + +void tst_QEasingCurve::metaTypes() +{ + QVERIFY(QMetaType::type("QEasingCurve") == QMetaType::QEasingCurve); + + QCOMPARE(QByteArray(QMetaType::typeName(QMetaType::QEasingCurve)), + QByteArray("QEasingCurve")); + + QVERIFY(QMetaType::isRegistered(QMetaType::QEasingCurve)); + + QVERIFY(qMetaTypeId<QEasingCurve>() == QMetaType::QEasingCurve); +} QTEST_MAIN(tst_QEasingCurve) #include "tst_qeasingcurve.moc" diff --git a/tests/benchmarks/declarative/binding/binding.pro b/tests/benchmarks/declarative/binding/binding.pro index e25f186..aa4cc41 100644 --- a/tests/benchmarks/declarative/binding/binding.pro +++ b/tests/benchmarks/declarative/binding/binding.pro @@ -7,3 +7,9 @@ macx:CONFIG -= app_bundle SOURCES += tst_binding.cpp testtypes.cpp HEADERS += testtypes.h +symbian* { + data.sources = data/* + data.path = data + DEPLOYMENT = data +} + diff --git a/tests/benchmarks/declarative/creation/creation.pro b/tests/benchmarks/declarative/creation/creation.pro index fcc2987..3e0caf6 100644 --- a/tests/benchmarks/declarative/creation/creation.pro +++ b/tests/benchmarks/declarative/creation/creation.pro @@ -6,5 +6,10 @@ macx:CONFIG -= app_bundle SOURCES += tst_creation.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" - +symbian* { + data.sources = data/* + data.path = data + DEPLOYMENT += addFiles +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +}
\ No newline at end of file diff --git a/tests/benchmarks/declarative/creation/tst_creation.cpp b/tests/benchmarks/declarative/creation/tst_creation.cpp index 23c820c..b99031a 100644 --- a/tests/benchmarks/declarative/creation/tst_creation.cpp +++ b/tests/benchmarks/declarative/creation/tst_creation.cpp @@ -49,6 +49,12 @@ #include <QmlGraphicsItem> #include <private/qobject_p.h> +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +// Application private dir is default serach path for files, so SRCDIR can be set to empty +#define SRCDIR "" +#endif + class tst_creation : public QObject { Q_OBJECT diff --git a/tests/benchmarks/declarative/qmlcomponent/qmlcomponent.pro b/tests/benchmarks/declarative/qmlcomponent/qmlcomponent.pro index 6a86f58..a77eebb 100644 --- a/tests/benchmarks/declarative/qmlcomponent/qmlcomponent.pro +++ b/tests/benchmarks/declarative/qmlcomponent/qmlcomponent.pro @@ -7,3 +7,13 @@ macx:CONFIG -= app_bundle SOURCES += tst_qmlcomponent.cpp testtypes.cpp HEADERS += testtypes.h +symbian* { + data.sources = data/* + data.path = data + samegame.sources = data/samegame/* + samegame.path = data/samegame + samegame_pics.sources = data/samegame/pics/* + samegame_pics.path = data/samegame/pics + DEPLOYMENT += data samegame samegame_pics +} + diff --git a/tests/benchmarks/declarative/qmlgraphicsimage/qmlgraphicsimage.pro b/tests/benchmarks/declarative/qmlgraphicsimage/qmlgraphicsimage.pro index 449d874..f14931c 100644 --- a/tests/benchmarks/declarative/qmlgraphicsimage/qmlgraphicsimage.pro +++ b/tests/benchmarks/declarative/qmlgraphicsimage/qmlgraphicsimage.pro @@ -7,5 +7,10 @@ CONFIG += release SOURCES += tst_qmlgraphicsimage.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" - +symbian* { + data.sources = image.png + data.path = . + DEPLOYMENT += data +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} diff --git a/tests/benchmarks/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp b/tests/benchmarks/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp index 7d7d24e..6d1aa0e 100644 --- a/tests/benchmarks/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp +++ b/tests/benchmarks/declarative/qmlgraphicsimage/tst_qmlgraphicsimage.cpp @@ -44,6 +44,12 @@ #include <QmlComponent> #include <private/qmlgraphicsimage_p.h> +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +// Application private dir is default serach path for files, so SRCDIR can be set to empty +#define SRCDIR "" +#endif + class tst_qmlgraphicsimage : public QObject { Q_OBJECT diff --git a/tests/benchmarks/declarative/qmltime/qmltime.cpp b/tests/benchmarks/declarative/qmltime/qmltime.cpp index cbac422..b791934 100644 --- a/tests/benchmarks/declarative/qmltime/qmltime.cpp +++ b/tests/benchmarks/declarative/qmltime/qmltime.cpp @@ -184,7 +184,11 @@ int main(int argc, char ** argv) } if (filename.isEmpty()) +#ifdef Q_OS_SYMBIAN + filename = QLatin1String("./tests/item_creation/data.qml"); +#else usage(argv[0]); +#endif QmlEngine engine; QmlComponent component(&engine, filename); @@ -205,6 +209,9 @@ int main(int argc, char ** argv) return -1; } +#ifdef Q_OS_SYMBIAN + willParent = true; +#endif timer->setWillParent(willParent); if (!timer->component()) { @@ -212,6 +219,10 @@ int main(int argc, char ** argv) return -1; } +#ifdef Q_OS_SYMBIAN + iterations = 1024; +#endif + timer->run(iterations); return 0; diff --git a/tests/benchmarks/declarative/qmltime/qmltime.pro b/tests/benchmarks/declarative/qmltime/qmltime.pro index b077d1a..9352f3b 100644 --- a/tests/benchmarks/declarative/qmltime/qmltime.pro +++ b/tests/benchmarks/declarative/qmltime/qmltime.pro @@ -6,3 +6,18 @@ macx:CONFIG -= app_bundle SOURCES += qmltime.cpp +symbian* { + TARGET.CAPABILITY = "All -TCB" + example.sources = example.qml + esample.path = . + tests.sources = tests/* + tests.path = tests + anshors.sources = tests/anchors/* + anchors.path = tests/anchors + item_creation.sources = tests/item_creation/* + item_creation.path = tests/item_creation + positioner_creation.sources = tests/positioner_creation/* + positioner_creation.path = tests/positioner_creation + DEPLOYMENT += example tests anchors item_creation positioner_creation +} + diff --git a/tests/benchmarks/declarative/script/script.pro b/tests/benchmarks/declarative/script/script.pro index 48fea81..6255acc 100644 --- a/tests/benchmarks/declarative/script/script.pro +++ b/tests/benchmarks/declarative/script/script.pro @@ -7,5 +7,14 @@ CONFIG += release SOURCES += tst_script.cpp -DEFINES += SRCDIR=\\\"$$PWD\\\" +symbian* { + data.sources = data/* + data.path = data + DEPLOYMENT += data +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} + + + diff --git a/tests/benchmarks/declarative/script/tst_script.cpp b/tests/benchmarks/declarative/script/tst_script.cpp index a90a98b..a11fe31 100644 --- a/tests/benchmarks/declarative/script/tst_script.cpp +++ b/tests/benchmarks/declarative/script/tst_script.cpp @@ -48,6 +48,12 @@ #include <QScriptEngine> #include <QScriptValue> +#ifdef Q_OS_SYMBIAN +// In Symbian OS test data is located in applications private dir +// Application private dir is default serach path for files, so SRCDIR can be set to empty +#define SRCDIR "." +#endif + class tst_script : public QObject { Q_OBJECT |