summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
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));