diff options
author | Ulf Hermann <ulf.hermann@qt.io> | 2018-10-16 15:49:24 +0200 |
---|---|---|
committer | Ulf Hermann <ulf.hermann@qt.io> | 2018-10-24 05:58:10 +0000 |
commit | c4f8f1db16b28e68016c926e2fe628c03513c6b4 (patch) | |
tree | 9f159a3deea866a734f9492500df97c011bc7c4a /tests/auto/qml/debugger | |
parent | ad73e0b045d9f75ec420dc55b12671cc00cf40be (diff) |
QmlDebug: Add QQmlInspectorClient
We use it in 2 tests and we might use it elsewhere, too.
Task-number: QTBUG-66504
Change-Id: I57e52e70044ac857482ecfe863f0d30698ab2e60
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'tests/auto/qml/debugger')
7 files changed, 2 insertions, 190 deletions
diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro index f69199f7d1..454a1e3ab0 100644 --- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro +++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/qqmlenginedebuginspectorintegrationtest.pro @@ -6,7 +6,6 @@ osx:CONFIG -= app_bundle SOURCES += tst_qqmlenginedebuginspectorintegration.cpp -include(../shared/qqmlinspectorclient.pri) include(../shared/debugutil.pri) TESTDATA = data/* diff --git a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp index 5e12a31163..980e2be1f1 100644 --- a/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebuginspectorintegrationtest/tst_qqmlenginedebuginspectorintegration.cpp @@ -26,12 +26,12 @@ ** ****************************************************************************/ -#include "qqmlinspectorclient.h" #include "../shared/debugutil_p.h" #include "../../../shared/util.h" #include <private/qqmldebugconnection_p.h> #include <private/qqmlenginedebugclient_p.h> +#include <private/qqmlinspectorclient_p.h> #include <QtTest/qtest.h> #include <QtTest/qsignalspy.h> diff --git a/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro index 3d4473c693..0d42030b52 100644 --- a/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro +++ b/tests/auto/qml/debugger/qqmlinspector/qqmlinspector.pro @@ -6,7 +6,6 @@ osx:CONFIG -= app_bundle SOURCES += tst_qqmlinspector.cpp -include(../shared/qqmlinspectorclient.pri) include(../shared/debugutil.pri) TESTDATA = data/* diff --git a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp index 5c9506eb21..6685558bb5 100644 --- a/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp +++ b/tests/auto/qml/debugger/qqmlinspector/tst_qqmlinspector.cpp @@ -26,12 +26,12 @@ ** ****************************************************************************/ -#include "qqmlinspectorclient.h" #include "../shared/debugutil_p.h" #include "../shared/qqmldebugprocess_p.h" #include "../../../shared/util.h" #include <private/qqmldebugconnection_p.h> +#include <private/qqmlinspectorclient_p.h> #include <QtTest/qtest.h> #include <QtTest/qsignalspy.h> diff --git a/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp b/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp deleted file mode 100644 index 20faef177e..0000000000 --- a/tests/auto/qml/debugger/shared/qqmlinspectorclient.cpp +++ /dev/null @@ -1,124 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qqmlinspectorclient.h" - -#include <private/qpacket_p.h> -#include <private/qqmldebugconnection_p.h> -#include <QtCore/qdebug.h> - -QQmlInspectorClient::QQmlInspectorClient(QQmlDebugConnection *connection) : - QQmlDebugClient(QLatin1String("QmlInspector"), connection), - m_lastRequestId(-1) -{ -} - -int QQmlInspectorClient::setInspectToolEnabled(bool enabled) -{ - QPacket ds(connection()->currentDataStreamVersion()); - ds << QByteArray("request") << ++m_lastRequestId - << QByteArray(enabled ? "enable" : "disable"); - - sendMessage(ds.data()); - return m_lastRequestId; -} - -int QQmlInspectorClient::setShowAppOnTop(bool showOnTop) -{ - QPacket ds(connection()->currentDataStreamVersion()); - ds << QByteArray("request") << ++m_lastRequestId - << QByteArray("showAppOnTop") << showOnTop; - - sendMessage(ds.data()); - return m_lastRequestId; -} - -int QQmlInspectorClient::setAnimationSpeed(qreal speed) -{ - QPacket ds(connection()->currentDataStreamVersion()); - ds << QByteArray("request") << ++m_lastRequestId - << QByteArray("setAnimationSpeed") << speed; - - sendMessage(ds.data()); - return m_lastRequestId; -} - -int QQmlInspectorClient::select(const QList<int> &objectIds) -{ - QPacket ds(connection()->currentDataStreamVersion()); - ds << QByteArray("request") << ++m_lastRequestId - << QByteArray("select") << objectIds; - - sendMessage(ds.data()); - return m_lastRequestId; -} - -int QQmlInspectorClient::createObject(const QString &qml, int parentId, const QStringList &imports, - const QString &filename) -{ - QPacket ds(connection()->currentDataStreamVersion()); - ds << QByteArray("request") << ++m_lastRequestId - << QByteArray("createObject") << qml << parentId << imports << filename; - sendMessage(ds.data()); - return m_lastRequestId; -} - -int QQmlInspectorClient::moveObject(int childId, int newParentId) -{ - QPacket ds(connection()->currentDataStreamVersion()); - ds << QByteArray("request") << ++m_lastRequestId - << QByteArray("moveObject") << childId << newParentId; - sendMessage(ds.data()); - return m_lastRequestId; -} - -int QQmlInspectorClient::destroyObject(int objectId) -{ - QPacket ds(connection()->currentDataStreamVersion()); - ds << QByteArray("request") << ++m_lastRequestId - << QByteArray("destroyObject") << objectId; - sendMessage(ds.data()); - return m_lastRequestId; -} - -void QQmlInspectorClient::messageReceived(const QByteArray &message) -{ - QPacket ds(connection()->currentDataStreamVersion(), message); - QByteArray type; - ds >> type; - - if (type != QByteArray("response")) { - qDebug() << "Unhandled message of type" << type; - return; - } - - int responseId; - bool result; - ds >> responseId >> result; - emit responseReceived(responseId, result); -} diff --git a/tests/auto/qml/debugger/shared/qqmlinspectorclient.h b/tests/auto/qml/debugger/shared/qqmlinspectorclient.h deleted file mode 100644 index bfb489c8f7..0000000000 --- a/tests/auto/qml/debugger/shared/qqmlinspectorclient.h +++ /dev/null @@ -1,59 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the test suite of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:GPL-EXCEPT$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QQMLINSPECTORCLIENT_H -#define QQMLINSPECTORCLIENT_H - -#include <private/qqmldebugclient_p.h> - -class QQmlInspectorClient : public QQmlDebugClient -{ - Q_OBJECT - -public: - QQmlInspectorClient(QQmlDebugConnection *connection); - - int setInspectToolEnabled(bool enabled); - int setShowAppOnTop(bool showOnTop); - int setAnimationSpeed(qreal speed); - int select(const QList<int> &objectIds); - int createObject(const QString &qml, int parentId, const QStringList &imports, - const QString &filename); - int moveObject(int childId, int newParentId); - int destroyObject(int objectId); - -signals: - void responseReceived(int requestId, bool result); - -protected: - void messageReceived(const QByteArray &message); - -private: - int m_lastRequestId; -}; - -#endif // QQMLINSPECTORCLIENT_H diff --git a/tests/auto/qml/debugger/shared/qqmlinspectorclient.pri b/tests/auto/qml/debugger/shared/qqmlinspectorclient.pri deleted file mode 100644 index c136e1313a..0000000000 --- a/tests/auto/qml/debugger/shared/qqmlinspectorclient.pri +++ /dev/null @@ -1,3 +0,0 @@ -HEADERS += $$PWD/qqmlinspectorclient.h - -SOURCES += $$PWD/qqmlinspectorclient.cpp |