mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
55f0b3b1f8
commit
b05e4c7b5f
5 changed files with 78 additions and 1 deletions
|
@ -1,3 +1,4 @@
|
||||||
|
- tests: add qml test harness
|
||||||
- Cloud storage: fix potential issue with credentials on Linux [#1346]
|
- Cloud storage: fix potential issue with credentials on Linux [#1346]
|
||||||
- Mobile/iOS: fix missing translations
|
- Mobile/iOS: fix missing translations
|
||||||
- Dive media: support addition of videos
|
- Dive media: support addition of videos
|
||||||
|
|
|
@ -224,7 +224,7 @@ if(BTSUPPORT)
|
||||||
list(APPEND QT_EXTRA_LIBRARIES Qt5::Bluetooth)
|
list(APPEND QT_EXTRA_LIBRARIES Qt5::Bluetooth)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
find_package(Qt5 REQUIRED COMPONENTS Core Concurrent Widgets Network Svg Test LinguistTools Positioning Quick Location ${QT_EXTRA_COMPONENTS})
|
find_package(Qt5 REQUIRED COMPONENTS Core Concurrent Widgets Network Svg Test QuickTest LinguistTools Positioning Quick Location ${QT_EXTRA_COMPONENTS})
|
||||||
set(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network Qt5::Svg Qt5::Positioning Qt5::Quick Qt5::Location ${QT_EXTRA_LIBRARIES})
|
set(QT_LIBRARIES Qt5::Core Qt5::Concurrent Qt5::Widgets Qt5::Network Qt5::Svg Qt5::Positioning Qt5::Quick Qt5::Location ${QT_EXTRA_LIBRARIES})
|
||||||
set(QT_TEST_LIBRARIES ${QT_LIBRARIES} Qt5::Test Qt5::QuickTest)
|
set(QT_TEST_LIBRARIES ${QT_LIBRARIES} Qt5::Test Qt5::QuickTest)
|
||||||
|
|
||||||
|
|
|
@ -76,6 +76,17 @@ enable_testing()
|
||||||
add_definitions(-g)
|
add_definitions(-g)
|
||||||
add_definitions(-DSUBSURFACE_TEST_DATA="${SUBSURFACE_TEST_DATA}")
|
add_definitions(-DSUBSURFACE_TEST_DATA="${SUBSURFACE_TEST_DATA}")
|
||||||
|
|
||||||
|
# Build QML test runner
|
||||||
|
add_executable(TestQML testqml.cpp )
|
||||||
|
target_link_libraries(
|
||||||
|
TestQML
|
||||||
|
subsurface_corelib
|
||||||
|
RESOURCE_LIBRARY
|
||||||
|
${QT_TEST_LIBRARIES}
|
||||||
|
${SUBSURFACE_LINK_LIBRARIES}
|
||||||
|
)
|
||||||
|
|
||||||
|
# SSRF test cases (TBD, convert to standard qTest setup)
|
||||||
TEST(TestUnitConversion testunitconversion.cpp)
|
TEST(TestUnitConversion testunitconversion.cpp)
|
||||||
TEST(TestProfile testprofile.cpp)
|
TEST(TestProfile testprofile.cpp)
|
||||||
TEST(TestGpsCoords testgpscoords.cpp)
|
TEST(TestGpsCoords testgpscoords.cpp)
|
||||||
|
@ -88,6 +99,7 @@ TEST(TestPreferences testpreferences.cpp)
|
||||||
TEST(TestPicture testpicture.cpp)
|
TEST(TestPicture testpicture.cpp)
|
||||||
TEST(TestMerge testmerge.cpp)
|
TEST(TestMerge testmerge.cpp)
|
||||||
TEST(TestTagList testtaglist.cpp)
|
TEST(TestTagList testtaglist.cpp)
|
||||||
|
add_test(NAME TestQML COMMAND $<TARGET_FILE:TestQML> ${SUBSURFACE_SOURCE}/tests)
|
||||||
|
|
||||||
|
|
||||||
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
|
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
|
||||||
|
@ -104,6 +116,7 @@ add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}
|
||||||
TestPicture
|
TestPicture
|
||||||
TestMerge
|
TestMerge
|
||||||
TestTagList
|
TestTagList
|
||||||
|
TestQML
|
||||||
)
|
)
|
||||||
|
|
||||||
# useful for debugging CMake issues
|
# useful for debugging CMake issues
|
||||||
|
|
46
tests/testqml.cpp
Normal file
46
tests/testqml.cpp
Normal file
|
@ -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
|
||||||
|
}
|
17
tests/tst_qPref.qml
Normal file
17
tests/tst_qPref.qml
Normal file
|
@ -0,0 +1,17 @@
|
||||||
|
// SPDX-License-Identifier: GPL-2.0
|
||||||
|
import QtQuick 2.6
|
||||||
|
import QtTest 1.2
|
||||||
|
import org.subsurfacedivelog.mobile 1.0
|
||||||
|
|
||||||
|
TestCase {
|
||||||
|
name: "qPref"
|
||||||
|
|
||||||
|
SsrfPrefs {
|
||||||
|
id: prefs
|
||||||
|
}
|
||||||
|
|
||||||
|
function test_register() {
|
||||||
|
var x = prefs.mobile_version
|
||||||
|
compare(x, prefs.mobile_version)
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue