diff options
author | Thiago Macieira <thiago.macieira@nokia.com> | 2011-02-10 22:35:31 (GMT) |
---|---|---|
committer | Thiago Macieira <thiago.macieira@nokia.com> | 2011-02-10 22:35:31 (GMT) |
commit | ca13ba801144763b1ca7c39b2ef8594de94e2d3e (patch) | |
tree | 7600e31df6ce715a5bc28c0c97983bac9484c7cb /tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp | |
parent | ab38731fe5dcfaa1a7a70bc290a8856b5b01524d (diff) | |
parent | ec20a6da3edea3031f1705c3b13e24dc2c7c6de5 (diff) | |
download | Qt-ca13ba801144763b1ca7c39b2ef8594de94e2d3e.zip Qt-ca13ba801144763b1ca7c39b2ef8594de94e2d3e.tar.gz Qt-ca13ba801144763b1ca7c39b2ef8594de94e2d3e.tar.bz2 |
Merge remote-tracking branch 'origin/4.7' into HEAD
Diffstat (limited to 'tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp index 4db538e..4340fce 100644 --- a/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp +++ b/tests/auto/declarative/qdeclarativecomponent/tst_qdeclarativecomponent.cpp @@ -44,6 +44,9 @@ #include <QtGui/qgraphicsitem.h> #include <QtDeclarative/qdeclarativeengine.h> #include <QtDeclarative/qdeclarativecomponent.h> +#include <QtDeclarative/qdeclarativeitem.h> +#include <QtDeclarative/qdeclarativeproperty.h> +#include <qcolor.h> #ifdef Q_OS_SYMBIAN // In Symbian OS test data is located in applications private dir @@ -60,6 +63,7 @@ private slots: void null(); void loadEmptyUrl(); void qmlCreateObject(); + void qmlCreateObjectWithProperties(); private: QDeclarativeEngine engine; @@ -118,6 +122,52 @@ void tst_qdeclarativecomponent::qmlCreateObject() QCOMPARE(testObject3->metaObject()->className(), "QDeclarativeGraphicsWidget"); } +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); + + QObject *testObject1 = object->property("declarativerectangle").value<QObject*>(); + QVERIFY(testObject1); + QVERIFY(testObject1->parent() == object); + QCOMPARE(testObject1->property("x").value<int>(), 17); + QCOMPARE(testObject1->property("y").value<int>(), 17); + QCOMPARE(testObject1->property("color").value<QColor>(), QColor(255,255,255)); + QCOMPARE(QDeclarativeProperty::read(testObject1,"border.width").toInt(), 3); + QCOMPARE(QDeclarativeProperty::read(testObject1,"innerRect.border.width").toInt(), 20); + delete testObject1; + + QObject *testObject2 = object->property("declarativeitem").value<QObject*>(); + QVERIFY(testObject2); + QVERIFY(testObject2->parent() == object); + //QCOMPARE(testObject2->metaObject()->className(), "QDeclarativeItem_QML_2"); + QCOMPARE(testObject2->property("x").value<int>(), 17); + QCOMPARE(testObject2->property("y").value<int>(), 17); + 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) #include "tst_qdeclarativecomponent.moc" |