diff options
Diffstat (limited to 'tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp')
-rw-r--r-- | tests/auto/qml/debugger/qqmlenginedebugservice/tst_qqmlenginedebugservice.cpp | 112 |
1 files changed, 27 insertions, 85 deletions
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<NonScriptProperty>("Test", 1, 0, "NonScriptPropertyElement"); QTest::ignoreMessage(QtDebugMsg, "QML Debugger: Waiting for connection on port 3768..."); m_engine = new QQmlEngine(this); - QList<QByteArray> 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<CustomTypes>("Backend", 1, 0, "CustomTypes"); - qml << "import Backend 1.0\n" - "CustomTypes {}" - ; - qmlRegisterType<JsonTest>("JsonTest", 1, 0, "JsonTest"); - qml << "import JsonTest 1.0\n" - "JsonTest {}" - ; - for (int i=0; i<qml.count(); i++) { - QQmlComponent component(m_engine); - component.setData(qml[i], QUrl::fromLocalFile("")); + // The contents of these files was previously hardcoded as QList<QByteArray> + // 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<QQuickItem*>(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); |