summaryrefslogtreecommitdiffstats
path: root/tests/auto/declarative
diff options
context:
space:
mode:
authorMartin Jones <martin.jones@nokia.com>2011-01-27 08:42:31 (GMT)
committerMartin Jones <martin.jones@nokia.com>2011-01-27 08:42:31 (GMT)
commit4f124cd0177aa79d17361c3d79669730b6d97adc (patch)
tree606cfcb652ee68a95481366860bb7575da4de707 /tests/auto/declarative
parentab71df83ba4eb9d749efc0f3a2d4a0fe5486023f (diff)
parent281ff52c266e54030ca48326e79eab2d452c2e83 (diff)
downloadQt-4f124cd0177aa79d17361c3d79669730b6d97adc.zip
Qt-4f124cd0177aa79d17361c3d79669730b6d97adc.tar.gz
Qt-4f124cd0177aa79d17361c3d79669730b6d97adc.tar.bz2
Merge branch 'qtquick11' of scm.dev.nokia.troll.no:qt/qt-qml into qtquick11
Diffstat (limited to 'tests/auto/declarative')
-rw-r--r--tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml17
-rw-r--r--tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp23
2 files changed, 38 insertions, 2 deletions
diff --git a/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml b/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml
index 60d4c44..6f9ddc1 100644
--- a/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml
+++ b/tests/auto/declarative/qdeclarativecomponent/data/createObjectWithScript.qml
@@ -4,6 +4,10 @@ Item{
id: root
property QtObject declarativerectangle : null
property QtObject declarativeitem : null
+
+ property QtObject bindingTestObject : null
+ property QtObject bindingThisTestObject : null
+
Component{id: a; Rectangle{} }
Component{
id: b
@@ -14,8 +18,21 @@ Item{
}
}
+ // test passing in bindings
+ width: 100
+ Component {
+ id: c
+ Item {
+ property int testValue
+ width: 300
+ }
+ }
+
Component.onCompleted: {
root.declarativerectangle = a.createObject(root, {"x":17,"y":17, "color":"white"});
root.declarativeitem = b.createObject(root, {"x":17,"y":17,"testBool":true,"testInt":17,"testObject":root});
+
+ root.bindingTestObject = c.createObject(root, {'testValue': (function(){return width * 3}) }) // use root.width
+ root.bindingThisTestObject = c.createObject(root, {'testValue': (function(){return this.width * 3}) }) // use width of Item within 'c'
}
}
diff --git a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
index 829b762..62c6bb5 100644
--- a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
+++ b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp
@@ -62,7 +62,7 @@ private slots:
void null();
void loadEmptyUrl();
void qmlCreateObject();
- void qmlCreatObjectWithScript();
+ void qmlCreateObjectWithProperties();
private:
QDeclarativeEngine engine;
@@ -121,10 +121,11 @@ void tst_qdeclarativecomponent::qmlCreateObject()
QCOMPARE(testObject3->metaObject()->className(), "QDeclarativeGraphicsWidget");
}
-void tst_qdeclarativecomponent::qmlCreatObjectWithScript()
+void tst_qdeclarativecomponent::qmlCreateObjectWithProperties()
{
QDeclarativeEngine engine;
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/createObjectWithScript.qml"));
+ QVERIFY2(component.errorString().isEmpty(), component.errorString().toUtf8());
QObject *object = component.create();
QVERIFY(object != 0);
@@ -134,6 +135,7 @@ void tst_qdeclarativecomponent::qmlCreatObjectWithScript()
QCOMPARE(testObject1->property("x").value<int>(), 17);
QCOMPARE(testObject1->property("y").value<int>(), 17);
QCOMPARE(testObject1->property("color").value<QColor>(), QColor(255,255,255));
+ delete testObject1;
QObject *testObject2 = object->property("declarativeitem").value<QObject*>();
QVERIFY(testObject2);
@@ -144,6 +146,23 @@ void tst_qdeclarativecomponent::qmlCreatObjectWithScript()
QCOMPARE(testObject2->property("testBool").value<bool>(), true);
QCOMPARE(testObject2->property("testInt").value<int>(), 17);
QCOMPARE(testObject2->property("testObject").value<QObject*>(), object);
+ delete testObject2;
+
+ QObject *testBindingObj = object->property("bindingTestObject").value<QObject*>();
+ QVERIFY(testBindingObj);
+ QCOMPARE(testBindingObj->parent(), object);
+ QCOMPARE(testBindingObj->property("testValue").value<int>(), 300);
+ object->setProperty("width", 150);
+ QCOMPARE(testBindingObj->property("testValue").value<int>(), 150 * 3);
+ delete testBindingObj;
+
+ QObject *testBindingThisObj = object->property("bindingThisTestObject").value<QObject*>();
+ QVERIFY(testBindingThisObj);
+ QCOMPARE(testBindingThisObj->parent(), object);
+ QCOMPARE(testBindingThisObj->property("testValue").value<int>(), 900);
+ testBindingThisObj->setProperty("width", 200);
+ QCOMPARE(testBindingThisObj->property("testValue").value<int>(), 200 * 3);
+ delete testBindingThisObj;
}
QTEST_MAIN(tst_qdeclarativecomponent)