diff options
author | Aurindam Jana <aurindam.jana@nokia.com> | 2012-05-10 09:21:26 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-12 11:00:34 +0200 |
commit | 6f9b3893c8c7bc0b6663acb34c17c120852ef7b7 (patch) | |
tree | f992993047106aead5d5228fb490120df7da490d /tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp | |
parent | 36d6307dd19d34354fb1ada7b6e5883977d43db8 (diff) |
QQmlDebugService: Fetch Objects for location info
Fetch Objects for given filename, line number and column
number.
Change-Id: I9a81e4c7fa75faaf87f02453026c5320b7f86003
Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp')
-rw-r--r-- | tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp | 74 |
1 files changed, 74 insertions, 0 deletions
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index 17b22b43a2..3c57c36f96 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -118,6 +118,8 @@ private slots: void queryRootContexts(); void queryObject(); void queryObject_data(); + void queryObjectsForLocation(); + void queryObjectsForLocation_data(); void queryExpressionResult(); void queryExpressionResult_data(); void queryExpressionResultInRootContext(); @@ -688,6 +690,78 @@ void tst_QQmlEngineDebugService::queryObject_data() QTest::newRow("recursive") << true; } +void tst_QQmlEngineDebugService::queryObjectsForLocation() +{ + QFETCH(bool, recursive); + + bool success; + + QmlDebugObjectReference rootObject = findRootObject(); + + const QString fileName = QFileInfo(rootObject.source.url.toString()).fileName(); + int lineNumber = rootObject.source.lineNumber; + int columnNumber = rootObject.source.columnNumber; + + QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0); + recursive ? unconnected->queryObjectsForLocationRecursive(fileName, lineNumber, + columnNumber, &success) + : unconnected->queryObjectsForLocation(fileName, lineNumber, + columnNumber, &success); + QVERIFY(!success); + delete unconnected; + + recursive ? m_dbg->queryObjectsForLocationRecursive(fileName, lineNumber, + columnNumber, &success) + : m_dbg->queryObjectsForLocation(fileName, lineNumber, + columnNumber, &success); + QVERIFY(success); + QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result()))); + + QVERIFY(m_dbg->objects().count() == 1); + QmlDebugObjectReference obj = m_dbg->objects().first(); + + // check source as defined in main() + QmlDebugFileReference source = obj.source; + QCOMPARE(source.url, QUrl(fileName)); + QCOMPARE(source.lineNumber, lineNumber); + QCOMPARE(source.columnNumber, columnNumber); + + // generically test all properties, children and childrens' properties + recursiveObjectTest(m_rootItem, obj, recursive); + + if (recursive) { + foreach (const QmlDebugObjectReference &child, obj.children) + QVERIFY(child.properties.count() > 0); + + QmlDebugObjectReference rect; + QmlDebugObjectReference text; + foreach (const QmlDebugObjectReference &child, obj.children) { + if (child.className == "Rectangle") + rect = child; + else if (child.className == "Text") + text = child; + } + + // test specific property values + QCOMPARE(findProperty(rect.properties, "width").value, qVariantFromValue(500)); + QCOMPARE(findProperty(rect.properties, "height").value, qVariantFromValue(600)); + QCOMPARE(findProperty(rect.properties, "color").value, qVariantFromValue(QColor("blue"))); + + QCOMPARE(findProperty(text.properties, "color").value, qVariantFromValue(QColor("blue"))); + } else { + foreach (const QmlDebugObjectReference &child, obj.children) + QCOMPARE(child.properties.count(), 0); + } +} + +void tst_QQmlEngineDebugService::queryObjectsForLocation_data() +{ + QTest::addColumn<bool>("recursive"); + + QTest::newRow("non-recursive") << false; + QTest::newRow("recursive") << true; +} + void tst_QQmlEngineDebugService::queryExpressionResult() { QFETCH(QString, expr); |