diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2010-11-10 13:31:53 (GMT) |
---|---|---|
committer | Kai Koehne <kai.koehne@nokia.com> | 2010-11-10 13:31:53 (GMT) |
commit | 0f46d1496b2cbb122f3ba314b57b0ab2f13e6e8d (patch) | |
tree | a7844975b3e6fb9ffebf91d495132316071ec04e /tests/auto/declarative/qdeclarativedebug | |
parent | 60a30394e3df9f7674d9c7c5b70f4963c2b1f293 (diff) | |
download | Qt-0f46d1496b2cbb122f3ba314b57b0ab2f13e6e8d.zip Qt-0f46d1496b2cbb122f3ba314b57b0ab2f13e6e8d.tar.gz Qt-0f46d1496b2cbb122f3ba314b57b0ab2f13e6e8d.tar.bz2 |
QDeclarativeDebug: Add autotest for [re]setBindingForObject
Add initial testing for setBindingForObject, resetBindingForObject in
QDeclarativeDebug.
Diffstat (limited to 'tests/auto/declarative/qdeclarativedebug')
-rw-r--r-- | tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index e6a81b8..f5f3284 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -112,6 +112,7 @@ private slots: void tst_QDeclarativeDebugContextReference(); void tst_QDeclarativeDebugPropertyReference(); + void setBindingForObject(); void setMethodBody(); }; @@ -894,6 +895,78 @@ void tst_QDeclarativeDebug::tst_QDeclarativeDebugPropertyReference() compareProperties(r, ref); } + +void tst_QDeclarativeDebug::setBindingForObject() +{ + QDeclarativeDebugObjectReference rootObject = findRootObject(); + QVERIFY(rootObject.debugId() != -1); + QDeclarativeDebugPropertyReference widthPropertyRef = findProperty(rootObject.properties(), "width"); + + QCOMPARE(widthPropertyRef.value(), QVariant(10)); + QCOMPARE(widthPropertyRef.binding(), QString()); + + // + // set literal + // + m_dbg->setBindingForObject(rootObject.debugId(), "width", "15", true); + + rootObject = findRootObject(); + widthPropertyRef = findProperty(rootObject.properties(), "width"); + + QCOMPARE(widthPropertyRef.value(), QVariant(15)); + QCOMPARE(widthPropertyRef.binding(), QString()); + + // + // set expression + // + m_dbg->setBindingForObject(rootObject.debugId(), "width", "height", false); + + rootObject = findRootObject(); + widthPropertyRef = findProperty(rootObject.properties(), "width"); + + QCOMPARE(widthPropertyRef.value(), QVariant(20)); + QCOMPARE(widthPropertyRef.binding(), QString("height")); + + // + // reset + // + m_dbg->resetBindingForObject(rootObject.debugId(), "width"); + + rootObject = findRootObject(); + widthPropertyRef = findProperty(rootObject.properties(), "width"); + + // QCOMPARE(widthPropertyRef.value(), QVariant(0)); // TODO: Shouldn't this work? + QCOMPARE(widthPropertyRef.binding(), QString()); + + // + // set handler + // + rootObject = findRootObject(); + QCOMPARE(rootObject.children().size(), 3); + QDeclarativeDebugObjectReference mouseAreaObject = rootObject.children().at(2); + QDeclarativeDebugObjectQuery *q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this); + waitForQuery(q_obj); + mouseAreaObject = q_obj->object(); + + QCOMPARE(mouseAreaObject.className(), QString("MouseArea")); + + QDeclarativeDebugPropertyReference onEnteredRef = findProperty(mouseAreaObject.properties(), "onEntered"); + + QCOMPARE(onEnteredRef.name(), QString("onEntered")); + QCOMPARE(onEnteredRef.value(), QVariant("{ console.log('hello') }")); + + m_dbg->setBindingForObject(mouseAreaObject.debugId(), "onEntered", "{console.log('hello, world') }", false) ; + + rootObject = findRootObject(); + mouseAreaObject = rootObject.children().at(2); + q_obj = m_dbg->queryObjectRecursive(mouseAreaObject, this); + waitForQuery(q_obj); + mouseAreaObject = q_obj->object(); + onEnteredRef = findProperty(mouseAreaObject.properties(), "onEntered"); + QCOMPARE(onEnteredRef.name(), QString("onEntered")); + QCOMPARE(onEnteredRef.value(), QVariant("{console.log('hello, world') }")); +} + int main(int argc, char *argv[]) { int _argc = argc + 1; |