From 078ff776e37aebe5b7e88e4b4f21da1158fac3c7 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 26 Mar 2010 14:29:19 +1000 Subject: Autotest tweaks. --- .../tst_qdeclarativebehaviors.cpp | 30 ++++++++++++++++++++++ .../qdeclarativebinding/data/test-binding.qml | 2 +- .../tst_qdeclarativebinding.cpp | 8 +++++- .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 3 +++ .../qdeclarativeloader/tst_qdeclarativeloader.cpp | 4 +++ 5 files changed, 45 insertions(+), 2 deletions(-) diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp index 0bf0b81..26c8231 100644 --- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp +++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp @@ -82,6 +82,8 @@ void tst_qdeclarativebehaviors::simpleBehavior() QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered + + delete rect; } void tst_qdeclarativebehaviors::scriptTriggered() @@ -95,6 +97,8 @@ void tst_qdeclarativebehaviors::scriptTriggered() QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered + + delete rect; } void tst_qdeclarativebehaviors::cppTriggered() @@ -111,6 +115,8 @@ void tst_qdeclarativebehaviors::cppTriggered() QTest::qWait(200); qreal x = innerRect->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered + + delete rect; } void tst_qdeclarativebehaviors::loop() @@ -122,6 +128,8 @@ void tst_qdeclarativebehaviors::loop() //don't crash rect->setState("moved"); + + delete rect; } void tst_qdeclarativebehaviors::colorBehavior() @@ -135,6 +143,8 @@ void tst_qdeclarativebehaviors::colorBehavior() QTest::qWait(200); QColor color = qobject_cast(rect->findChild("MyRect"))->color(); QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered + + delete rect; } void tst_qdeclarativebehaviors::parentBehavior() @@ -152,6 +162,8 @@ void tst_qdeclarativebehaviors::parentBehavior() QTest::qWait(600); parent = rect->findChild("MyRect")->parentItem(); QVERIFY(parent == newParent); + + delete rect; } void tst_qdeclarativebehaviors::replaceBinding() @@ -186,6 +198,8 @@ void tst_qdeclarativebehaviors::replaceBinding() rect->setProperty("basex", 20); QTest::qWait(600); QCOMPARE(innerRect->x(), (qreal)20); + + delete rect; } void tst_qdeclarativebehaviors::group() @@ -200,6 +214,8 @@ void tst_qdeclarativebehaviors::group() QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered + + delete rect; } { @@ -212,6 +228,8 @@ void tst_qdeclarativebehaviors::group() QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered + + delete rect; } } @@ -225,6 +243,8 @@ void tst_qdeclarativebehaviors::emptyBehavior() rect->setState("moved"); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately + + delete rect; } void tst_qdeclarativebehaviors::explicitSelection() @@ -239,6 +259,8 @@ void tst_qdeclarativebehaviors::explicitSelection() QTest::qWait(200); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered + + delete rect; } } @@ -253,6 +275,8 @@ void tst_qdeclarativebehaviors::nonSelectingBehavior() rect->setState("moved"); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately + + delete rect; } } @@ -266,6 +290,8 @@ void tst_qdeclarativebehaviors::reassignedAnimation() QCOMPARE(qobject_cast( qobject_cast( rect->findChild("MyBehavior"))->animation())->duration(), 200); + + delete rect; } void tst_qdeclarativebehaviors::disabled() @@ -279,6 +305,8 @@ void tst_qdeclarativebehaviors::disabled() rect->setState("moved"); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately + + delete rect; } void tst_qdeclarativebehaviors::dontStart() @@ -294,6 +322,8 @@ void tst_qdeclarativebehaviors::dontStart() QDeclarativeAbstractAnimation *myAnim = rect->findChild("MyAnim"); QVERIFY(myAnim && myAnim->qtAnimation()); QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + + delete rect; } QTEST_MAIN(tst_qdeclarativebehaviors) diff --git a/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml b/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml index e9101e4..8f5b39e 100644 --- a/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml +++ b/tests/auto/declarative/qdeclarativebinding/data/test-binding.qml @@ -12,5 +12,5 @@ Rectangle { Binding { target: screen; property: "text"; value: s1.text; objectName: "binding1" } Binding { target: screen; property: "color"; value: r1.color } - Binding { target: screen; property: "color"; when: screen.changeColor == true; value: r2.color } + Binding { target: screen; property: "color"; when: screen.changeColor == true; value: r2.color; objectName: "binding3" } } diff --git a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp index 483d588..8ab7b0b 100644 --- a/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp +++ b/tests/auto/declarative/qdeclarativebinding/tst_qdeclarativebinding.cpp @@ -69,14 +69,20 @@ void tst_qdeclarativebinding::binding() QDeclarativeEngine engine; QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/test-binding.qml")); QDeclarativeRectangle *rect = qobject_cast(c.create()); - QVERIFY(rect != 0); + + QDeclarativeBind *binding3 = qobject_cast(rect->findChild("binding3")); + QVERIFY(binding3 != 0); + QCOMPARE(rect->color(), QColor("yellow")); QCOMPARE(rect->property("text").toString(), QString("Hello")); + QCOMPARE(binding3->when(), false); rect->setProperty("changeColor", true); QCOMPARE(rect->color(), QColor("red")); + QCOMPARE(binding3->when(), true); + QDeclarativeBind *binding = qobject_cast(rect->findChild("binding1")); QVERIFY(binding != 0); QCOMPARE(binding->object(), qobject_cast(rect)); diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index bbf7421..c1bf2b8 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -156,6 +156,9 @@ void tst_qdeclarativeimage::imageSource() QDeclarativeImage *obj = qobject_cast(component.create()); QVERIFY(obj != 0); + if (async) + QVERIFY(obj->asynchronous() == true); + if (remote || async) TRY_WAIT(obj->status() == QDeclarativeImage::Loading); diff --git a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp index a745a24..05d968c 100644 --- a/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp +++ b/tests/auto/declarative/qdeclarativeloader/tst_qdeclarativeloader.cpp @@ -129,6 +129,10 @@ void tst_QDeclarativeLoader::component() QCOMPARE(loader->status(), QDeclarativeLoader::Ready); QCOMPARE(static_cast(loader)->children().count(), 1); + QDeclarativeComponent *c = qobject_cast(item->QGraphicsObject::children().at(0)); + QVERIFY(c); + QCOMPARE(loader->sourceComponent(), c); + delete loader; } -- cgit v0.12