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 @@ -260,6 +260,10 @@ if (ENABLE_TESTS)
)
endif ()

if (SquishQtBuiltinHook_ROOT)
find_package(SquishQtBuiltinHook)
endif ()

# ########################################################################################
# GLOBAL SETUP
# ########################################################################################
Expand Down Expand Up @@ -361,6 +365,10 @@ if (ANDROID)
# Make sure the generator for android_deployment_settings.json can figure out the
# architecture
list(APPEND CMAKE_FIND_ROOT_PATH /)
# Make sure the generator for android_deployment_settings.json can find Squish libs
if (SquishQtBuiltinHook_ROOT)
list(APPEND CMAKE_FIND_ROOT_PATH ${SquishQtBuiltinHook_ROOT})
endif ()
endif ()

# ########################################################################################
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")`
26 changes: 26 additions & 0 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -339,13 +339,27 @@ if (ANDROID)
${CMAKE_CURRENT_SOURCE_DIR}/android/build.gradle @ONLY
)

if (SquishQtBuiltinHook_FOUND)
squish_qt_add_builtin_hook(MerginMaps ATTACH_PORT 7757)
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"
)
endif ()

set_target_properties(
MerginMaps
PROPERTIES QT_ANDROID_PACKAGE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/android
QT_ANDROID_TARGET_SDK_VERSION ${MM_ANDROID_TARGET_SDK_VERSION}
QT_ANDROID_MIN_SDK_VERSION ${MM_ANDROID_MIN_SDK_VERSION}
QT_ANDROID_VERSION_CODE ${MM_VERSION_CODE}
QT_ANDROID_VERSION_NAME ${MM_VERSION}
QT_ANDROID_EXTRA_LIBS "${SquishLibs}"
)
endif ()

Expand Down Expand Up @@ -439,6 +453,15 @@ if (IOS)
)
message(STATUS "Using automatic code sign")
endif ()

#squish
if (SquishQtBuiltinHook_FOUND)
squish_qt_add_builtin_hook(MerginMaps ATTACH_PORT 7757)
target_include_directories(
MerginMaps
PRIVATE "${SquishQtBuiltinHook_ROOT}/include"
)
endif ()
endif ()

# ########################################################################################
Expand Down Expand Up @@ -554,6 +577,9 @@ if (IOS)
)
# TODO is this needed? this change requires cmake 3.28+
# qt_add_ios_ffmpeg_libraries(MerginMaps) # Qt Multimedia
if (SquishQtBuiltinHook_FOUND)
target_link_libraries(MerginMaps PRIVATE SquishQtBuiltinHook)
endif ()
endif ()

if (WIN)
Expand Down
1 change: 1 addition & 0 deletions app/qml/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ set(MM_QML
components/MMToolbar.qml
components/MMToolbarButton.qml
components/MMSingleClickMouseArea.qml
components/MMStackView.qml
components/private/MMBaseInput.qml
components/private/MMBaseSingleLineInput.qml
components/private/MMToolbarLongButton.qml
Expand Down
27 changes: 27 additions & 0 deletions app/qml/components/MMStackView.qml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/

import QtQuick
import QtQuick.Controls

// StackView wrapper, which improves Squish support. Should be used instead of pure QML StackView.

StackView {
id: root

onEmptyChanged: function() {
visible = !empty
}

Component.onCompleted: {
if (empty) {
visible = false
}
}
}
4 changes: 3 additions & 1 deletion app/qml/form/MMFormStackController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import QtQuick
import QtQuick.Controls

import MMInput

Item {
id: root

Expand Down Expand Up @@ -252,7 +254,7 @@ Item {
form.controllerToApply = null
}

StackView {
MMStackView {
id: formsStack

function popOneOrClose() {
Expand Down
3 changes: 2 additions & 1 deletion app/qml/layers/MMLayersController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import QtQuick
import QtQuick.Controls

import mm 1.0 as MM
import MMInput

import "../components"
import "../inputs"
Expand Down Expand Up @@ -41,7 +42,7 @@ Item {
}
}

StackView {
MMStackView {
id: pagesStackView

anchors.fill: parent
Expand Down
2 changes: 1 addition & 1 deletion app/qml/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ ApplicationWindow {
onClosed: stateManager.state = "map"
}

StackView {
MMStackView {
id: mapPanelsStackView

//
Expand Down
3 changes: 2 additions & 1 deletion app/qml/project/MMProjectController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import Qt5Compat.GraphicalEffects
import QtQuick.Dialogs

import mm 1.0 as MM
import MMInput

import "../components"
import "../inputs"
Expand Down Expand Up @@ -88,7 +89,7 @@ Item {
stackView.focus = true
}

StackView {
MMStackView {
id: stackView

initialItem: workspaceProjectsPanelComp
Expand Down
2 changes: 1 addition & 1 deletion app/qml/settings/MMSettingsController.qml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Item {
}


StackView {
MMStackView {
id: stackview

width: ApplicationWindow.window?.width ?? 0
Expand Down
4 changes: 3 additions & 1 deletion gallery/qml/pages/OnboardingPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Layouts

import MMInput

import "../../app/qml/components"
import "../../app/qml/account"

Page {
id: root

StackView {
MMStackView {
id: stackview

anchors.fill: parent
Expand Down
4 changes: 3 additions & 1 deletion gallery/qml/pages/PagesPage.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import QtQuick
import QtQuick.Controls
import QtQuick.Controls.Basic

import MMInput

import "../../app/qml/components"
import "../../app/qml"
import "../../app/qml/project"
Expand All @@ -21,7 +23,7 @@ import "../../app/qml/account"
Page {
id: root

StackView {
MMStackView {
id: stackview

anchors.fill: parent
Expand Down
Loading