aboutsummaryrefslogtreecommitdiffstats
path: root/tests/auto/qml/debugger
diff options
context:
space:
mode:
authorSimjees Abraham <simjees.abraham@nokia.com>2012-05-11 14:37:33 +0200
committerQt by Nokia <qt-info@nokia.com>2012-05-14 13:58:03 +0200
commit7eb5f7b3e0630d59bfa7e4e185df6f34c237e584 (patch)
treef4a769907beec334e628266032ce8b7436016b00 /tests/auto/qml/debugger
parentfd5c099eea26a8101e2cc0dc3237d1250158b895 (diff)
Inspector:Modified Apply changes on Save for unsync. changes
Changes done to reload the view if the user opts to do so after making unsynchronizable changes. Inspector informs the QmlEngine about the changes which caches it. The cache is used to load the files which were changed when reloading the view. Change-Id: I22d476cace294d6ecf4e428dac104a557c3f7dde Reviewed-by: Aaron Kennedy <aaron.kennedy@nokia.com>
Diffstat (limited to 'tests/auto/qml/debugger')
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/data/changes.txt8
-rw-r--r--tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp44
2 files changed, 50 insertions, 2 deletions
diff --git a/tests/auto/qml/debugger/qqmlinspector/data/changes.txt b/tests/auto/qml/debugger/qqmlinspector/data/changes.txt
new file mode 100644
index 0000000000..38b17caeff
--- /dev/null
+++ b/tests/auto/qml/debugger/qqmlinspector/data/changes.txt
@@ -0,0 +1,8 @@
+import QtQuick 2.0
+Item {
+ id: test
+ Component.onCompleted: {
+ console.log("version 2.0");
+ Qt.quit()
+ }
+}
diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
index 611dc2b843..5326a053b0 100644
--- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
+++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp
@@ -62,10 +62,12 @@ public:
, m_showAppOnTop(false)
, m_requestId(0)
, m_requestResult(false)
+ , m_responseId(-1)
{
}
void setShowAppOnTop(bool showOnTop);
+ void reloadQml(const QHash<QString, QByteArray> &changesHash);
signals:
void responseReceived();
@@ -79,6 +81,8 @@ private:
public:
bool m_requestResult;
+ int m_responseId;
+ int m_reloadRequestId;
};
class tst_QQmlInspector : public QQmlDataTest
@@ -105,6 +109,7 @@ private slots:
void connect();
void showAppOnTop();
+ void reloadQml();
};
@@ -118,6 +123,18 @@ void QQmlInspectorClient::setShowAppOnTop(bool showOnTop)
sendMessage(message);
}
+void QQmlInspectorClient::reloadQml(const QHash<QString, QByteArray> &changesHash)
+{
+ QByteArray message;
+ QDataStream ds(&message, QIODevice::WriteOnly);
+ m_reloadRequestId = m_requestId;
+
+ ds << QByteArray("request") << m_requestId++
+ << QByteArray("reload") << changesHash;
+
+ sendMessage(message);
+}
+
void QQmlInspectorClient::messageReceived(const QByteArray &message)
{
QDataStream ds(message);
@@ -130,8 +147,7 @@ void QQmlInspectorClient::messageReceived(const QByteArray &message)
}
m_requestResult = false;
- int requestId;
- ds >> requestId >> m_requestResult;
+ ds >> m_responseId >> m_requestResult;
emit responseReceived();
}
@@ -179,6 +195,30 @@ void tst_QQmlInspector::showAppOnTop()
QCOMPARE(m_client->m_requestResult, true);
}
+void tst_QQmlInspector::reloadQml()
+{
+ QTRY_COMPARE(m_client->state(), QQmlDebugClient::Enabled);
+
+ QByteArray fileContents;
+
+ QFile file(testFile("changes.txt"));
+ if (file.open(QFile::ReadOnly))
+ fileContents = file.readAll();
+ file.close();
+
+ QHash<QString, QByteArray> changesHash;
+ changesHash.insert("qtquick2.qml", fileContents);
+
+ m_client->reloadQml(changesHash);
+ QVERIFY(QQmlDebugTest::waitForSignal(m_client, SIGNAL(responseReceived())));
+
+ QTRY_COMPARE(m_process->output().contains(
+ QString("version 2.0")), true);
+
+ QCOMPARE(m_client->m_requestResult, true);
+ QCOMPARE(m_client->m_reloadRequestId, m_client->m_responseId);
+}
+
QTEST_MAIN(tst_QQmlInspector)
#include "tst_qqmlinspector.moc"