summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative/qmldom/tst_qmldom.cpp
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2009-05-05 00:43:51 (GMT)
committerMartin Jones <martin.jones@nokia.com>2009-05-05 00:43:51 (GMT)
commit22959526d81bfd2195d389eddc88c626350b6925 (patch)
treeb3dd0df107e4e15ded2b30e40ae4d721428bf61c /tests/auto/declarative/qmldom/tst_qmldom.cpp
parent0e75846b831bbeb4794cc4e3d00cd3096726d35e (diff)
parentfab8fa152901cb84132f11b52f950c0dbb6d7a23 (diff)
downloadQt-22959526d81bfd2195d389eddc88c626350b6925.zip
Qt-22959526d81bfd2195d389eddc88c626350b6925.tar.gz
Qt-22959526d81bfd2195d389eddc88c626350b6925.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
Diffstat (limited to 'tests/auto/declarative/qmldom/tst_qmldom.cpp')
-rw-r--r--tests/auto/declarative/qmldom/tst_qmldom.cpp35
1 files changed, 34 insertions, 1 deletions
diff --git a/tests/auto/declarative/qmldom/tst_qmldom.cpp b/tests/auto/declarative/qmldom/tst_qmldom.cpp
index 7e7e067..36d37f6 100644
--- a/tests/auto/declarative/qmldom/tst_qmldom.cpp
+++ b/tests/auto/declarative/qmldom/tst_qmldom.cpp
@@ -16,6 +16,8 @@ private slots:
void loadProperties();
void loadChildObject();
+ void testValueSource();
+
private:
QmlEngine engine;
};
@@ -63,7 +65,7 @@ void tst_qmldom::loadProperties()
void tst_qmldom::loadChildObject()
{
- QByteArray qml = "Item { Item }";
+ QByteArray qml = "Item { Item {} }";
//QByteArray qml = "<Item> <Item/> </Item>";
QmlDomDocument document;
@@ -85,6 +87,37 @@ void tst_qmldom::loadChildObject()
QVERIFY(childItem.objectType() == "Item");
}
+void tst_qmldom::testValueSource()
+{
+ QByteArray qml = "Rect { height: Follow { spring: 1.4; damping: .15; source: Math.min(Math.max(-130, value*2.2 - 130), 133); }}";
+
+ QmlEngine freshEngine;
+ QmlDomDocument document;
+ QVERIFY(document.load(&freshEngine, qml));
+
+ QmlDomObject rootItem = document.rootObject();
+ QVERIFY(rootItem.isValid());
+ QmlDomProperty heightProperty = rootItem.properties().at(0);
+ QVERIFY(heightProperty.propertyName() == "height");
+ QVERIFY(heightProperty.value().isValueSource());
+
+ const QmlDomValueValueSource valueSource = heightProperty.value().toValueSource();
+ QmlDomObject valueSourceObject = valueSource.object();
+ QVERIFY(valueSourceObject.isValid());
+
+ QVERIFY(valueSourceObject.objectType() == "Follow");
+
+ const QmlDomValue springValue = valueSourceObject.property("spring").value();
+ QVERIFY(!springValue.isInvalid());
+ QVERIFY(springValue.isLiteral());
+ QVERIFY(springValue.toLiteral().literal() == "1.4");
+
+ const QmlDomValue sourceValue = valueSourceObject.property("source").value();
+ QVERIFY(!sourceValue.isInvalid());
+ QVERIFY(sourceValue.isBinding());
+ QVERIFY(sourceValue.toBinding().binding() == "Math.min(Math.max(-130, value*2.2 - 130), 133)");
+}
+
QTEST_MAIN(tst_qmldom)
#include "tst_qmldom.moc"