aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/debugger/qqmlenginedebugservice
diff options
context:
space:
mode:
authorAurindam Jana <aurindam.jana@nokia.com>2012-05-09 11:30:27 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-09 12:23:11 +0200
commitc6c3673143ee1ceef686a014373bd99da1bddabd (patch)
tree149895f624257f3050cef2e45509805c0959dc54 /tests/auto/qml/debugger/qqmlenginedebugservice
parente211cedddefb7c7d29987d63cc2dac6491ec7ce6 (diff)
QQmlEngineDebugService: Query Expression
If the scope object is null or if there no QML context for the scope object, try to use the root context of the engine. Change-Id: I0068ea36f18a179b44791b81a2f6b8ec5423f615 Reviewed-by: Kai Koehne <kai.koehne@nokia.com>
Diffstat (limited to 'tests/auto/qml/debugger/qqmlenginedebugservice')
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp20
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.h3
-rw-r--r--tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp50
3 files changed, 72 insertions, 1 deletions
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp
index 0c5dfddffa..eb04fb2c2e 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.cpp
@@ -241,7 +241,25 @@ quint32 QQmlEngineDebugClient::queryExpressionResult(
m_exprResult = QVariant();
quint32 id;
*success = false;
- if (state() == QQmlDebugClient::Enabled && objectDebugId != -1) {
+ if (state() == QQmlDebugClient::Enabled) {
+ id = getId();
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ ds << QByteArray("EVAL_EXPRESSION") << id << objectDebugId << expr
+ << engines()[0].debugId;
+ sendMessage(message);
+ *success = true;
+ }
+ return id;
+}
+
+quint32 QQmlEngineDebugClient::queryExpressionResultBC(
+ int objectDebugId, const QString &expr, bool *success)
+{
+ m_exprResult = QVariant();
+ quint32 id;
+ *success = false;
+ if (state() == QQmlDebugClient::Enabled) {
id = getId();
QByteArray message;
QDataStream ds(&message, QIODevice::WriteOnly);
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.h b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.h
index 62f9b15824..34d4e971a1 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.h
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/qqmlenginedebugclient.h
@@ -197,6 +197,9 @@ public:
quint32 queryExpressionResult(int objectDebugId,
const QString &expr,
bool *success);
+ quint32 queryExpressionResultBC(int objectDebugId,
+ const QString &expr,
+ bool *success);
quint32 setBindingForObject(int objectDebugId, const QString &propertyName,
const QVariant &bindingExpression,
bool isLiteralValue,
diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
index cc1193b0f1..17b22b43a2 100644
--- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
+++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp
@@ -120,6 +120,9 @@ private slots:
void queryObject_data();
void queryExpressionResult();
void queryExpressionResult_data();
+ void queryExpressionResultInRootContext();
+ void queryExpressionResultBC();
+ void queryExpressionResultBC_data();
void setBindingForObject();
void setMethodBody();
@@ -721,6 +724,53 @@ void tst_QQmlEngineDebugService::queryExpressionResult_data()
QTest::newRow("varObjMap") << "varObjMap" << qVariantFromValue(map);
}
+void tst_QQmlEngineDebugService::queryExpressionResultInRootContext()
+{
+ bool success;
+ const QString exp = QLatin1String("1");
+ m_dbg->queryExpressionResult(-1, exp, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+
+ QCOMPARE(m_dbg->resultExpr().toString(), exp);
+}
+
+void tst_QQmlEngineDebugService::queryExpressionResultBC()
+{
+ QFETCH(QString, expr);
+ QFETCH(QVariant, result);
+
+ int objectId = findRootObject().debugId;
+
+ bool success;
+
+ QQmlEngineDebugClient *unconnected = new QQmlEngineDebugClient(0);
+ unconnected->queryExpressionResultBC(objectId, expr, &success);
+ QVERIFY(!success);
+ delete unconnected;
+
+ m_dbg->queryExpressionResultBC(objectId, expr, &success);
+ QVERIFY(success);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_dbg, SIGNAL(result())));
+
+ QCOMPARE(m_dbg->resultExpr(), result);
+}
+
+void tst_QQmlEngineDebugService::queryExpressionResultBC_data()
+{
+ QTest::addColumn<QString>("expr");
+ QTest::addColumn<QVariant>("result");
+
+ QTest::newRow("width + 50") << "width + 50" << qVariantFromValue(60);
+ QTest::newRow("blueRect.width") << "blueRect.width" << qVariantFromValue(500);
+ QTest::newRow("bad expr") << "aeaef" << qVariantFromValue(QString("<undefined>"));
+ QTest::newRow("QObject*") << "varObj" << qVariantFromValue(QString("<unnamed object>"));
+ QTest::newRow("list of QObject*") << "varObjList" << qVariantFromValue(QString("<unknown value>"));
+ QVariantMap map;
+ map.insert(QLatin1String("rect"), QVariant(QLatin1String("<unnamed object>")));
+ QTest::newRow("varObjMap") << "varObjMap" << qVariantFromValue(map);
+}
+
void tst_QQmlEngineDebugService::setBindingForObject()
{
QmlDebugObjectReference rootObject = findRootObject();