summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2022-04-05 09:31:39 +0200
committerUlf Hermann <ulf.hermann@qt.io>2022-04-05 11:08:49 +0200
commit2962ea59fb7e7763f8719905b76a932b4a7ad53b (patch)
tree9d6b6b145e708617a5418c18f58779c646c369ce /tests
parente847c99555e057ef7646bd572130af9da9b92cb5 (diff)
Clean up qqmlstatemachinemetatype test
We need to expose the test data in the CMakeLists.txt so that qmlimportscanner can pick it up. We also want to see the error string if the instantiation fails. This test only worked on Android because of a different bug that makes Android tests pass if the data collection fails. Pick-to: 6.2 6.3 Task-number: QTBUG-102252 Change-Id: I0c7dee57eca9ab2dedf7818c91ce55e32d658c42 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Diffstat (limited to 'tests')
-rw-r--r--tests/auto/qml/qqmlstatemachinemetatype/CMakeLists.txt23
-rw-r--r--tests/auto/qml/qqmlstatemachinemetatype/data/unregisterAttachedProperties.qml7
-rw-r--r--tests/auto/qml/qqmlstatemachinemetatype/tst_qqmlstatemachinemetatype.cpp15
3 files changed, 32 insertions, 13 deletions
diff --git a/tests/auto/qml/qqmlstatemachinemetatype/CMakeLists.txt b/tests/auto/qml/qqmlstatemachinemetatype/CMakeLists.txt
index 28c126b..f7bad06 100644
--- a/tests/auto/qml/qqmlstatemachinemetatype/CMakeLists.txt
+++ b/tests/auto/qml/qqmlstatemachinemetatype/CMakeLists.txt
@@ -1,17 +1,34 @@
-
#####################################################################
## tst_qqmlstatemachinemetatype 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_qqmlstatemachinemetatype
SOURCES
+ ../../shared/util.cpp ../../shared/util.h
tst_qqmlstatemachinemetatype.cpp
+ INCLUDE_DIRECTORIES
+ ../../shared
PUBLIC_LIBRARIES
Qt::CorePrivate
Qt::Gui
Qt::GuiPrivate
Qt::QmlPrivate
+ TESTDATA ${test_data}
+)
+
+qt_internal_extend_target(tst_qqmlstatemachinemetatype CONDITION ANDROID OR IOS
+ DEFINES
+ QT_QMLTEST_DATADIR=\\\":/data\\\"
+)
+
+qt_internal_extend_target(tst_qqmlstatemachinemetatype CONDITION NOT ANDROID AND NOT IOS
+ DEFINES
+ QT_QMLTEST_DATADIR=\\\"${CMAKE_CURRENT_SOURCE_DIR}/data\\\"
)
-## Scopes:
-#####################################################################
diff --git a/tests/auto/qml/qqmlstatemachinemetatype/data/unregisterAttachedProperties.qml b/tests/auto/qml/qqmlstatemachinemetatype/data/unregisterAttachedProperties.qml
new file mode 100644
index 0000000..ee26be6
--- /dev/null
+++ b/tests/auto/qml/qqmlstatemachinemetatype/data/unregisterAttachedProperties.qml
@@ -0,0 +1,7 @@
+// The extra import shuffles the type IDs around, so that we
+// get a different ID for the attached properties. If the attached
+// properties aren't properly cleared, this will crash.
+
+import QtQml.StateMachine 1.0
+import QtQuick 2.2
+Item { KeyNavigation.up: null }
diff --git a/tests/auto/qml/qqmlstatemachinemetatype/tst_qqmlstatemachinemetatype.cpp b/tests/auto/qml/qqmlstatemachinemetatype/tst_qqmlstatemachinemetatype.cpp
index 186e512..06c0dbd 100644
--- a/tests/auto/qml/qqmlstatemachinemetatype/tst_qqmlstatemachinemetatype.cpp
+++ b/tests/auto/qml/qqmlstatemachinemetatype/tst_qqmlstatemachinemetatype.cpp
@@ -26,6 +26,8 @@
**
****************************************************************************/
+#include "../../shared/util.h"
+
#include <qtest.h>
#include <qqmlengine.h>
#include <qqmlcomponent.h>
@@ -33,7 +35,7 @@
#include <private/qqmlmetatype_p.h>
#include <private/qqmlengine_p.h>
-class tst_qqmlstatemachinemetatype : public QObject
+class tst_qqmlstatemachinemetatype : public QQmlDataTest
{
Q_OBJECT
@@ -41,17 +43,10 @@ private slots:
void unregisterAttachedProperties()
{
qmlClearTypeRegistrations();
- const QUrl dummy("qrc:///doesnotexist.qml");
QQmlEngine e;
- QQmlComponent c(&e);
-
- // The extra import shuffles the type IDs around, so that we
- // get a different ID for the attached properties. If the attached
- // properties aren't properly cleared, this will crash.
- c.setData("import QtQml.StateMachine 1.0 \n"
- "import QtQuick 2.2 \n"
- "Item { KeyNavigation.up: null }", dummy);
+ QQmlComponent c(&e, testFileUrl("unregisterAttachedProperties.qml"));
+ QVERIFY2(c.isReady(), qPrintable(c.errorString()));
const QQmlType attachedType = QQmlMetaType::qmlType("QtQuick/KeyNavigation",
QTypeRevision::fromVersion(2, 2));