diff options
Diffstat (limited to 'tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp')
-rw-r--r-- | tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp | 78 |
1 files changed, 77 insertions, 1 deletions
diff --git a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp index e6a81b8..45bb10e 100644 --- a/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp +++ b/tests/auto/declarative/qdeclarativedebug/tst_qdeclarativedebug.cpp @@ -59,6 +59,7 @@ #include <private/qdeclarativerectangle_p.h> #include <private/qdeclarativemetatype_p.h> #include <private/qdeclarativeproperty_p.h> +#include <private/qdeclarativedebughelper_p.h> #include "../../../shared/util.h" #include "../shared/debugutil_p.h" @@ -112,6 +113,7 @@ private slots: void tst_QDeclarativeDebugContextReference(); void tst_QDeclarativeDebugPropertyReference(); + void setBindingForObject(); void setMethodBody(); }; @@ -278,8 +280,10 @@ void tst_QDeclarativeDebug::initTestCase() { qRegisterMetaType<QDeclarativeDebugWatch::State>(); - QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3768..."); + QTest::ignoreMessage(QtWarningMsg, "Qml debugging is enabled. Only use this in a safe environment!"); + QDeclarativeDebugHelper::enableDebugging(); + QTest::ignoreMessage(QtWarningMsg, "QDeclarativeDebugServer: Waiting for connection on port 3768..."); m_engine = new QDeclarativeEngine(this); QList<QByteArray> qml; @@ -894,6 +898,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; |