summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Brasser <michael.brasser@nokia.com>2010-04-29 09:56:53 +1000
committerMichael Brasser <michael.brasser@nokia.com>2010-04-29 10:16:12 +1000
commitefab34ea95560db007b1a75cce63cf8f6431a683 (patch)
treeeecf3654d42d09267949efe0f4e17fc7258fcbe9
parentb3fc4d9671cf885cbd7145f125af9da190716d78 (diff)
downloadqt4-tools-efab34ea95560db007b1a75cce63cf8f6431a683.tar.gz
Additional Behavior test + text fixes.
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml16
-rw-r--r--tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp65
2 files changed, 58 insertions, 23 deletions
diff --git a/tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml b/tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml
new file mode 100644
index 0000000000..1911cc4eb5
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativebehaviors/data/startup2.qml
@@ -0,0 +1,16 @@
+import Qt 4.7
+
+Rectangle {
+ width: 800;
+ height: 480;
+
+ Text { id:theText; text: "hello world" }
+
+ Rectangle {
+ objectName: "innerRect"
+ color: "red"
+ x: theText.width
+ Behavior on x { NumberAnimation {} }
+ width: 100; height: 100
+ }
+}
diff --git a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
index ee9e282fbb..5e0c9d5890 100644
--- a/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
+++ b/tests/auto/declarative/qdeclarativebehaviors/tst_qdeclarativebehaviors.cpp
@@ -43,6 +43,7 @@
#include <QtDeclarative/qdeclarativecomponent.h>
#include <QtDeclarative/qdeclarativeview.h>
#include <private/qdeclarativerectangle_p.h>
+#include <private/qdeclarativetext_p.h>
#include <private/qdeclarativebehavior_p.h>
#include <private/qdeclarativeanimation_p.h>
#include "../../../shared/util.h"
@@ -230,11 +231,11 @@ void tst_qdeclarativebehaviors::emptyBehavior()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QVERIFY(rect);
rect->setState("moved");
qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
- QTRY_COMPARE(x, qreal(200)); //should change immediately
+ QCOMPARE(x, qreal(200)); //should change immediately
delete rect;
}
@@ -244,7 +245,7 @@ void tst_qdeclarativebehaviors::explicitSelection()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QVERIFY(rect);
rect->setState("moved");
QTRY_VERIFY(qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x() > 0);
@@ -259,11 +260,11 @@ void tst_qdeclarativebehaviors::nonSelectingBehavior()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QVERIFY(rect);
rect->setState("moved");
qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
- QTRY_COMPARE(x, qreal(200)); //should change immediately
+ QCOMPARE(x, qreal(200)); //should change immediately
delete rect;
}
@@ -275,10 +276,9 @@ void tst_qdeclarativebehaviors::reassignedAnimation()
QString warning = QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml").toString() + ":9:9: QML Behavior: Cannot change the animation assigned to a Behavior.";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QTRY_VERIFY(rect);
- QTRY_COMPARE(qobject_cast<QDeclarativeNumberAnimation*>(
- qobject_cast<QDeclarativeBehavior*>(
- rect->findChild<QDeclarativeBehavior*>("MyBehavior"))->animation())->duration(), 200);
+ QVERIFY(rect);
+ QCOMPARE(qobject_cast<QDeclarativeNumberAnimation*>(
+ rect->findChild<QDeclarativeBehavior*>("MyBehavior")->animation())->duration(), 200);
delete rect;
}
@@ -288,12 +288,12 @@ void tst_qdeclarativebehaviors::disabled()
QDeclarativeEngine engine;
QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml"));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QTRY_VERIFY(rect);
- QTRY_COMPARE(rect->findChild<QDeclarativeBehavior*>("MyBehavior")->enabled(), false);
+ QVERIFY(rect);
+ QCOMPARE(rect->findChild<QDeclarativeBehavior*>("MyBehavior")->enabled(), false);
rect->setState("moved");
qreal x = qobject_cast<QDeclarativeRectangle*>(rect->findChild<QDeclarativeRectangle*>("MyRect"))->x();
- QTRY_COMPARE(x, qreal(200)); //should change immediately
+ QCOMPARE(x, qreal(200)); //should change immediately
delete rect;
}
@@ -307,28 +307,47 @@ void tst_qdeclarativebehaviors::dontStart()
QString warning = c.url().toString() + ":13:13: QML NumberAnimation: setRunning() cannot be used on non-root animation nodes.";
QTest::ignoreMessage(QtWarningMsg, qPrintable(warning));
QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ QVERIFY(rect);
QDeclarativeAbstractAnimation *myAnim = rect->findChild<QDeclarativeAbstractAnimation*>("MyAnim");
- QTRY_VERIFY(myAnim && myAnim->qtAnimation());
- QTRY_VERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
+ QVERIFY(myAnim && myAnim->qtAnimation());
+ QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped);
delete rect;
}
void tst_qdeclarativebehaviors::startup()
{
- QDeclarativeEngine engine;
- QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup.qml"));
- QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
- QTRY_VERIFY(rect);
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
- QDeclarativeRectangle *innerRect = rect->findChild<QDeclarativeRectangle*>("innerRect");
- QTRY_VERIFY(innerRect);
+ QDeclarativeRectangle *innerRect = rect->findChild<QDeclarativeRectangle*>("innerRect");
+ QVERIFY(innerRect);
- QTRY_COMPARE(innerRect->x(), qreal(100)); //should be set immediately
+ QCOMPARE(innerRect->x(), qreal(100)); //should be set immediately
- delete rect;
+ delete rect;
+ }
+
+ {
+ QDeclarativeEngine engine;
+ QDeclarativeComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/startup2.qml"));
+ QDeclarativeRectangle *rect = qobject_cast<QDeclarativeRectangle*>(c.create());
+ QVERIFY(rect);
+
+ QDeclarativeRectangle *innerRect = rect->findChild<QDeclarativeRectangle*>("innerRect");
+ QVERIFY(innerRect);
+
+ QDeclarativeText *text = rect->findChild<QDeclarativeText*>();
+ QVERIFY(text);
+
+ QCOMPARE(innerRect->x(), text->width()); //should be set immediately
+
+ delete rect;
+ }
}
QTEST_MAIN(tst_qdeclarativebehaviors)