Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -260,6 +264,10 @@ if (ENABLE_TESTS)
)
endif ()

if (SquishQtBuiltinHook_ROOT)
find_package(SquishQtBuiltinHook)
endif ()

# ########################################################################################
# GLOBAL SETUP
# ########################################################################################
Expand Down
28 changes: 27 additions & 1 deletion INSTALL.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -641,4 +642,29 @@ TEST_API_PASSWORD=<your_password>
```

Build binary, and you can run tests either with `ctest` or you can run individual tests by adding `--test<TestName>`
e.g. ` ./MerginMaps --testMerginApi`
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=/<path>/<to>/<squish-for-android>/<directory>/`.
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 \<No Application\>.
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")`
21 changes: 21 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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 ()
Loading