summaryrefslogtreecommitdiffstats
path: root/tests/testqml.cpp
diff options
context:
space:
mode:
authorGravatar jan Iversen <jani@apache.org>2018-07-07 18:55:24 +0200
committerGravatar jan Iversen <jani@apache.org>2018-07-12 17:12:56 +0200
commitb05e4c7b5fb4e858a997086caaeb7dc680394a34 (patch)
treef613f15efad35b9f723c92c043ddb161776633e0 /tests/testqml.cpp
parent55f0b3b1f8ac641fc29ffdbb166b9b6947d7eb03 (diff)
downloadsubsurface-b05e4c7b5fb4e858a997086caaeb7dc680394a34.tar.gz
tests: make qml test harness
build a qml test runner that includes ssrf interface The qml test runner allows having qml test files. Signed-off-by: Jan Iversen <jani@apache.org>
Diffstat (limited to 'tests/testqml.cpp')
-rw-r--r--tests/testqml.cpp46
1 files changed, 46 insertions, 0 deletions
diff --git a/tests/testqml.cpp b/tests/testqml.cpp
new file mode 100644
index 000000000..fe411f0bb
--- /dev/null
+++ b/tests/testqml.cpp
@@ -0,0 +1,46 @@
+// SPDX-License-Identifier: GPL-2.0
+#include <QQmlEngine>
+#include <QtQuickTest>
+#include <QtTest>
+#include <QQmlEngine>
+#include <QQmlContext>
+
+#include "core/settings/qPref.h"
+
+
+// this is the content of QUICK_TEST_MAIN amended with
+// registration of ssrf classes
+int main(int argc, char **argv)
+{
+ // QML testing is not supported in the oldest Qt versions we support
+ // if running with Qt version less than 5.10 then skip test
+#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0)
+ QTEST_ADD_GPU_BLACKLIST_SUPPORT
+ QTEST_SET_MAIN_SOURCE_PATH
+
+ // check that qPref exists
+ new qPref;
+
+ // check that we have a directory
+ if (argc < 2) {
+ qDebug() << "ERROR: missing tst_* directory";
+ return -1;
+ }
+ // save tst_dir and pass rest to Qt
+ const char *tst_dir = argv[1];
+ for (int i = 1; i < argc; i++)
+ argv[i] = argv[i+1];
+ argc--;
+
+ // Register types
+ auto rc = qmlRegisterType<qPref>("org.subsurfacedivelog.mobile", 1, 0, "SsrfPrefs");
+ if (rc < 0) {
+ qDebug() << "ERROR: cannot register qPref";
+ return -1;
+ }
+
+ return quick_test_main(argc, argv, "TestQML", tst_dir);
+#else
+ return 0;
+#endif
+}