From ecc87ea07723998dcfa947353e4259ec8d057035 Mon Sep 17 00:00:00 2001 From: Ivan Solovev Date: Wed, 27 Apr 2022 11:50:42 +0200 Subject: Android: enable tst_qqmlenginedebugservice The test was failing because it was using QML code that was embedded directly in the test, so the dependencies were not detected and deployed. This patch moves QML code into separate files, so that qmlimportscanner could provide all the necessary dependencies. Fixes: QTBUG-100166 Pick-to: 6.3 6.2 Change-Id: I5581de9a4573204722ad60eaceae8d05a491eb13 Reviewed-by: Assam Boudjelthia --- .../debugger/qqmlenginedebugservice/CMakeLists.txt | 7 ++ .../qqmlenginedebugservice/data/complexItem.qml | 54 ++++++++++ .../qqmlenginedebugservice/data/customTypes.qml | 31 ++++++ .../qqmlenginedebugservice/data/emptyItem.qml | 31 ++++++ .../data/itemWithFunctions.qml | 34 +++++++ .../qqmlenginedebugservice/data/jsonTest.qml | 31 ++++++ .../data/rectangleWithTransitions.qml | 53 ++++++++++ .../tst_qqmlenginedebugservice.cpp | 112 +++++---------------- 8 files changed, 268 insertions(+), 85 deletions(-) create mode 100644 tests/auto/qml/debugger/qqmlenginedebugservice/data/complexItem.qml create mode 100644 tests/auto/qml/debugger/qqmlenginedebugservice/data/customTypes.qml create mode 100644 tests/auto/qml/debugger/qqmlenginedebugservice/data/emptyItem.qml create mode 100644 tests/auto/qml/debugger/qqmlenginedebugservice/data/itemWithFunctions.qml create mode 100644 tests/auto/qml/debugger/qqmlenginedebugservice/data/jsonTest.qml create mode 100644 tests/auto/qml/debugger/qqmlenginedebugservice/data/rectangleWithTransitions.qml (limited to 'tests/auto/qml/debugger') diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/CMakeLists.txt b/tests/auto/qml/debugger/qqmlenginedebugservice/CMakeLists.txt index 9afe16c4ad..e632f91548 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/CMakeLists.txt +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/CMakeLists.txt @@ -4,6 +4,12 @@ ## tst_qqmlenginedebugservice Test: ##################################################################### +# Collect test data +file(GLOB_RECURSE test_data_glob + RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} + data/*) +list(APPEND test_data ${test_data_glob}) + qt_internal_add_test(tst_qqmlenginedebugservice SOURCES ../shared/debugutil.cpp ../shared/debugutil_p.h @@ -19,6 +25,7 @@ qt_internal_add_test(tst_qqmlenginedebugservice Qt::QmlPrivate Qt::Quick Qt::QuickTestUtilsPrivate + TESTDATA ${test_data} ) ## Scopes: diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/data/complexItem.qml b/tests/auto/qml/debugger/qqmlenginedebugservice/data/complexItem.qml new file mode 100644 index 0000000000..ae8b681013 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/data/complexItem.qml @@ -0,0 +1,54 @@ +/**************************************************************************** +** +** Copyright (C) 2022 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$ +** +****************************************************************************/ + +import QtQuick 2.0 +import Test 1.0 +Item { + id: root + width: 10; height: 20; scale: blueRect.scale; + Rectangle { id: blueRect; width: 500; height: 600; color: "blue"; } + Text { font.bold: true; color: blueRect.color; } + MouseArea { + onEntered: { console.log('hello') } + } + property variant varObj + property variant varObjList: [] + property variant varObjMap + property variant simpleVar: 10.05 + Component.onCompleted: { + varObj = blueRect; + var list = varObjList; + list[0] = blueRect; + varObjList = list; + var map = new Object; + map.rect = blueRect; + varObjMap = map; + } + NonScriptPropertyElement { + } +} diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/data/customTypes.qml b/tests/auto/qml/debugger/qqmlenginedebugservice/data/customTypes.qml new file mode 100644 index 0000000000..21c0ee84ba --- /dev/null +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/data/customTypes.qml @@ -0,0 +1,31 @@ +/**************************************************************************** +** +** Copyright (C) 2022 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$ +** +****************************************************************************/ + +import Backend 1.0 +CustomTypes { +} diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/data/emptyItem.qml b/tests/auto/qml/debugger/qqmlenginedebugservice/data/emptyItem.qml new file mode 100644 index 0000000000..9bff34e1e5 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/data/emptyItem.qml @@ -0,0 +1,31 @@ +/**************************************************************************** +** +** Copyright (C) 2022 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$ +** +****************************************************************************/ + +import QtQuick 2.0 +Item { +} diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/data/itemWithFunctions.qml b/tests/auto/qml/debugger/qqmlenginedebugservice/data/itemWithFunctions.qml new file mode 100644 index 0000000000..ba1617cb37 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/data/itemWithFunctions.qml @@ -0,0 +1,34 @@ +/**************************************************************************** +** +** Copyright (C) 2022 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$ +** +****************************************************************************/ + +import QtQuick 2.0 +Item { + function myMethodNoArgs() { return 3; } + function myMethod(a) { return a + 9; } + function myMethodIndirect() { myMethod(3); } +} diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/data/jsonTest.qml b/tests/auto/qml/debugger/qqmlenginedebugservice/data/jsonTest.qml new file mode 100644 index 0000000000..53cae7a271 --- /dev/null +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/data/jsonTest.qml @@ -0,0 +1,31 @@ +/**************************************************************************** +** +** Copyright (C) 2022 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$ +** +****************************************************************************/ + +import JsonTest 1.0 +JsonTest { +} diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/data/rectangleWithTransitions.qml b/tests/auto/qml/debugger/qqmlenginedebugservice/data/rectangleWithTransitions.qml new file mode 100644 index 0000000000..5447c1577a --- /dev/null +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/data/rectangleWithTransitions.qml @@ -0,0 +1,53 @@ +/**************************************************************************** +** +** Copyright (C) 2022 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$ +** +****************************************************************************/ + +import QtQuick 2.0 +Rectangle { + id: rootRect + width: 100 + states: [ + State { + name: "state1" + PropertyChanges { + target: rootRect + width: 200 + } + } + ] + transitions: [ + Transition { + from: "*" + to: "state1" + PropertyAnimation { + target: rootRect + property: "width" + duration: 100 + } + } + ] +} diff --git a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp index 9f96f2ca72..bed8cb9c46 100644 --- a/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp +++ b/tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp @@ -119,12 +119,13 @@ private: }; -class tst_QQmlEngineDebugService : public QObject +class tst_QQmlEngineDebugService : public QQmlDataTest { Q_OBJECT public: tst_QQmlEngineDebugService() - : m_conn(nullptr) + : QQmlDataTest(QT_QMLTEST_DATADIR) + , m_conn(nullptr) , m_dbg(nullptr) , m_engine(nullptr) , m_rootItem(nullptr) {} @@ -150,7 +151,7 @@ private: QObjectList m_components; private slots: - void initTestCase(); + void initTestCase() override; void cleanupTestCase(); void watch_property(); @@ -331,93 +332,34 @@ void tst_QQmlEngineDebugService::getContexts() void tst_QQmlEngineDebugService::initTestCase() { + QQmlDataTest::initTestCase(); + qmlRegisterType("Test", 1, 0, "NonScriptPropertyElement"); QTest::ignoreMessage(QtDebugMsg, "QML Debugger: Waiting for connection on port 3768..."); m_engine = new QQmlEngine(this); - QList qml; - qml << "import QtQuick 2.0\n" - "import Test 1.0\n" - "Item {" - "id: root\n" - "width: 10; height: 20; scale: blueRect.scale;" - "Rectangle { id: blueRect; width: 500; height: 600; color: \"blue\"; }" - "Text { font.bold: true; color: blueRect.color; }" - "MouseArea {" - "onEntered: { console.log('hello') }" - "}" - "property variant varObj\n" - "property variant varObjList: []\n" - "property variant varObjMap\n" - "property variant simpleVar: 10.05\n" - "Component.onCompleted: {\n" - "varObj = blueRect;\n" - "var list = varObjList;\n" - "list[0] = blueRect;\n" - "varObjList = list;\n" - "var map = new Object;\n" - "map.rect = blueRect;\n" - "varObjMap = map;\n" - "}\n" - "NonScriptPropertyElement {\n" - "}\n" - "}"; - - // add second component to test multiple root contexts - qml << "import QtQuick 2.0\n" - "Item {}"; - - // and a third to test methods - qml << "import QtQuick 2.0\n" - "Item {" - "function myMethodNoArgs() { return 3; }\n" - "function myMethod(a) { return a + 9; }\n" - "function myMethodIndirect() { myMethod(3); }\n" - "}"; - - // and a fourth to test states - qml << "import QtQuick 2.0\n" - "Rectangle {\n" - "id:rootRect\n" - "width:100\n" - "states: [\n" - "State {\n" - "name:\"state1\"\n" - "PropertyChanges {\n" - "target:rootRect\n" - "width:200\n" - "}\n" - "}\n" - "]\n" - "transitions: [\n" - "Transition {\n" - "from:\"*\"\n" - "to:\"state1\"\n" - "PropertyAnimation {\n" - "target:rootRect\n" - "property:\"width\"\n" - "duration:100\n" - "}\n" - "}\n" - "]\n" - "}\n" - ; - - // test non-streamable properties qmlRegisterType("Backend", 1, 0, "CustomTypes"); - qml << "import Backend 1.0\n" - "CustomTypes {}" - ; - qmlRegisterType("JsonTest", 1, 0, "JsonTest"); - qml << "import JsonTest 1.0\n" - "JsonTest {}" - ; - for (int i=0; i + // directly in this test, but that fails on Android, because the required + // dependencies are not deployed. When the contents is moved to separate + // files, qmlimportscanner is capable of providing all the necessary + // dependencies. + // Note that the order of the files in this list matters! The test-cases + // expect Qml components to be created is certain order. + constexpr const char *fileNames[] = { + "complexItem.qml", + "emptyItem.qml", + "itemWithFunctions.qml", + "rectangleWithTransitions.qml", + "customTypes.qml", + "jsonTest.qml" + }; + + for (auto file : fileNames) { + QQmlComponent component(m_engine, testFileUrl(file)); QVERIFY(component.isReady()); // fails if bad syntax m_components << qobject_cast(component.create()); } @@ -756,8 +698,8 @@ void tst_QQmlEngineDebugService::queryObject() // check source as defined in main() QQmlEngineDebugFileReference source = obj.source; - QCOMPARE(source.url, QUrl::fromLocalFile("")); - QCOMPARE(source.lineNumber, 3); + QCOMPARE(source.url, testFileUrl("complexItem.qml")); + QCOMPARE(source.lineNumber, 31); // because of license header QCOMPARE(source.columnNumber, 1); // generically test all properties, children and childrens' properties @@ -835,7 +777,7 @@ void tst_QQmlEngineDebugService::queryObjectsForLocation() // check source as defined in main() QQmlEngineDebugFileReference source = obj.source; - QCOMPARE(source.url, QUrl(fileName)); + QCOMPARE(source.url, testFileUrl(fileName)); QCOMPARE(source.lineNumber, lineNumber); QCOMPARE(source.columnNumber, columnNumber); -- cgit v1.2.3