diff --git a/CMakeLists.txt b/CMakeLists.txt index 652a7a031..efbc014df 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -162,6 +162,10 @@ message(STATUS "Mergin Maps Mobile ${version_desc} - ${platform_desc}") # FIND PACKAGES # ######################################################################################## +if (SquishQtBuiltinHook_ROOT) + list(APPEND CMAKE_FIND_ROOT_PATH ${SquishQtBuiltinHook_ROOT}) +endif () + find_package( Qt6 COMPONENTS Quick @@ -260,6 +264,10 @@ if (ENABLE_TESTS) ) endif () +if (SquishQtBuiltinHook_ROOT) + find_package(SquishQtBuiltinHook) +endif () + # ######################################################################################## # GLOBAL SETUP # ######################################################################################## diff --git a/INSTALL.md b/INSTALL.md index 461a92e22..d1113eb00 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -627,6 +627,7 @@ Once the project is opened, build it from Xcode. # 9. Auto Testing +## Mergin API tests You need to add cmake define `-DENABLE_TESTING=TRUE` on your cmake configure line. Also, you need to open Passbolt and check for password for user `test_mobileapp` on `app.dev.merginmaps.com`, or you need some user with unlimited projects limit. First workspace from list is taken. @@ -641,4 +642,29 @@ TEST_API_PASSWORD= ``` Build binary, and you can run tests either with `ctest` or you can run individual tests by adding `--test` -e.g. ` ./MerginMaps --testMerginApi` \ No newline at end of file +e.g. ` ./MerginMaps --testMerginApi` + +## Squish tests +### Prerequisites + - Squish for Qt for Android (ARMv8/ARMv7 depending on architecture you build for) + - Squish for Qt (Windows/Mac/Linux), this should also include the Squish IDE +### Android +After you unpack both and install Squish IDE, add another cmake argument `-DSquishQtBuiltinHook_ROOT=/////`. +This will build the apk with squish hook inside. You can verify that squish is working by finding these lines in log after startup: +```shell +I/Squish (26459): Setting SQUISH_PREFIX to '/data/data/uk.co.lutraconsulting' +I/Squish (26459): libMerginMaps_arm64-v8a.so[26459]: Loading Qt Wrapper configuration from ":/squish/etc/qtwrapper.ini" +I/Squish (26459): libMerginMaps_arm64-v8a.so[26459]: QObject lifetime tracking is disabled +I/Squish (26459): libMerginMaps_arm64-v8a.so[26459]: Listening on port 7757 for incoming connections +``` + +In the squish IDE it's necessary to follow these steps to set it up completely and start testing the application. +1. In Squish IDE choose File, New Test Suite to create a new Test Suite and follow the wizard. When asked for the GUI Toolkit choose Qt. When asked for the Application Under Test choose \. +2. [Register attachable AUT](https://doc.qt.io/squish/attaching-to-running-applications.html#register-the-attachable-aut) + 1. As _Name_ set `MerginMaps`, _Host_ is the IP address of your phone (has to be on the same Wifi) and set _Port_ to `7757` + 2. You can also use USB cable to connect both devices. However, there is some further setup to do, first you need to forward the device port to your PC with: + ```shell + $ adb forward tcp:portnumber tcp:portnumber + ``` + After that the setup is the same as in point 1, just _Host_ will become `localhost`. +3. The test script should start with `attachToApplication("MerginMaps")` \ No newline at end of file diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index e49bfd223..04f71dae1 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -606,3 +606,24 @@ qt_add_qml_module( QML_FILES ${MM_QML_SRCS} RESOURCE_PREFIX /com.merginmaps/imports ) + +# ######################################################################################## +# Other +# ######################################################################################## + +if (ANDROID AND SquishQtBuiltinHook_FOUND) + squish_qt_add_builtin_hook(MerginMaps ATTACH_PORT 7757) + # copy squish hook libs + list( + APPEND + SquishLibs + "${SquishQtBuiltinHook_ROOT}/lib/libsquishhook.so" + "${SquishQtBuiltinHook_ROOT}/lib/libsquishqtquickcommon.so" + "${SquishQtBuiltinHook_ROOT}/lib/libsquishqtwrapper.so" + "${SquishQtBuiltinHook_ROOT}/lib/extensions/qt/libsquishqgraphicsview.so" + "${SquishQtBuiltinHook_ROOT}/lib/extensions/qt/libsquishqtabwidget.so" + "${SquishQtBuiltinHook_ROOT}/lib/extensions/qt/libsquishqtquick.so" + "${SquishQtBuiltinHook_ROOT}/lib/extensions/qt/libsquishqtquicktypes.so" + ) + set_target_properties(MerginMaps PROPERTIES QT_ANDROID_EXTRA_LIBS "${SquishLibs}") +endif ()