gui-qml
gui-qml copied to clipboard
Create QML test automation target (qml/test/test_bitcoin-qt)
Adds src/qml/test/test_bitcoin-qt as a new test target. This program is built using the QuickTest library. It can be used to validate our qml code by rederimg our components and providing simulated user input. It is set to only be built if QuickTest library is found, gui tests are enabled, and bitcoin-qt is configured for qml.
As a part of test setup, a test implementation of our imageprovider is added to the test target to avoid bringing in too many dependencies. Additionally, a fake AppMode component is added to mock setting the device layout mode.
More information about the QuickTest library can be found at https://doc.qt.io/qt-5.15/qtquicktest-index.html.
@johnny9
Thank you very much for working on tests!
Mind adding some words to the PR description?
tst_*.qml is actually the pattern the library uses to find test cases in a directory.
Still have some linking issues with Makefile.qmltest.include it seems as CI isn't happy. I likely linked too make things into the binary.
Still have some linking issues with Makefile.qmltest.include it seems as CI isn't happy. I likely linked too make things into the binary.
Looking into them...
Static builds, which all builds with depends are, require importing of plugins like this:
--- a/src/qml/test/onboardingtests.cpp
+++ b/src/qml/test/onboardingtests.cpp
@@ -1,11 +1,32 @@
// Copyright (c) 2023 The Bitcoin Core developers
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#include <qml/test/onboardingtests.h>
+
+#if defined(HAVE_CONFIG_H)
+#include <config/bitcoin-config.h>
+#endif
+
#include <QtQuickTest>
#include <QQmlEngine>
#include <QQmlContext>
#include <qml/test/testimageprovider.h>
-#include <qml/test/onboardingtests.h>
+
+#if defined(QT_STATICPLUGIN)
+#include <QtPlugin>
+Q_IMPORT_PLUGIN(QtQuick2Plugin)
+Q_IMPORT_PLUGIN(QTestQmlModule)
+#if defined(QT_QPA_PLATFORM_XCB)
+Q_IMPORT_PLUGIN(QXcbIntegrationPlugin);
+#elif defined(QT_QPA_PLATFORM_WINDOWS)
+Q_IMPORT_PLUGIN(QWindowsIntegrationPlugin);
+#elif defined(QT_QPA_PLATFORM_COCOA)
+Q_IMPORT_PLUGIN(QCocoaIntegrationPlugin);
+#elif defined(QT_QPA_PLATFORM_ANDROID)
+Q_IMPORT_PLUGIN(QAndroidPlatformIntegrationPlugin)
+#endif
+#endif
Setup::Setup()
{
And add to build-aux/m4/bitcoin_qt.m4
a few lines QT_LIBS="$QT_LIBS -L$qt_plugin_path/../qml/QtTest"
and _BITCOIN_QT_CHECK_STATIC_PLUGIN([QTestQmlModule], [-lqmltestplugin])
(did not test yet).
Maybe, label this PR as a draft for now?
FWIW, I'm testing this PR on Ubuntu 22.04 with depends:
$ make -C depends NO_WALLET=1 NO_ZMQ=1 NO_UPNP=1 NO_NATPMP=1 NO_QR=1
$ ./autogen.sh
$ ./configure --disable-fuzz-binary --disable-bench CONFIG_SITE=$PWD/depends/x86_64-pc-linux-gnu/share/config.site
$ make clean
$ make
From https://doc.qt.io/qt-5/qtquicktest-index.html:
Note: There is no binary compatibility guarantee for the Qt Quick Test module. This means that an application that uses Qt Quick Test is only guaranteed to work with the Qt version it was developed against. However, source compatibility is guaranteed.
Should we skip Quick test when building with depends?
Thank you for the review Hebasto. Very helpful. Marked as a draft and will unmark after addressing the issues you've mentioned and am more confident it can get through CI.
@johnny9
Here is a quick and dirty branch which is built successfully in all CI tasks. However, running qml/test/test_bitcoin-qt
in the CI environment needs more investigation regarding which value of the QT_QPA_PLATFORM
variable should be used.
Feel free to use my branch at your discretion.
@johnny9
Here is a quick and dirty branch which is built successfully in all CI tasks. However, running
qml/test/test_bitcoin-qt
in the CI environment needs more investigation regarding which value of theQT_QPA_PLATFORM
variable should be used.Feel free to use my branch at your discretion.
Thank you. I'll take a look at it and merge it with my branch. I made an attempt last night but struggled with the QT STATIC PLUGIN checks. I'll be investigating how to get this supported in cirrus afterwards. I have some ideas but it'll depend on what kind of platform support they have for a buffer to render into. I'd like to use this to validate the qml in our PRs and maybe even generate screenshots since that eats up a lot of review time.
I made an attempt last night but struggled with the QT STATIC PLUGIN checks.
Still thinking it doesn't worth. See https://github.com/bitcoin-core/gui-qml/pull/215#issuecomment-1382813668.
The qml/pages/onboarding/OnboardingWizard.qml
is still to be added to QML_RES_QML
.
Might the introducing of src/qml/pages/onboarding/OnboardingWizard.qml
be split up into its own PR?
Might the introducing of
src/qml/pages/onboarding/OnboardingWizard.qml
be split up into its own PR?
Yeah I can do that. It was done to simplify testing but the change is generally good as the main,qml gets simpler.
Need to cleanup the commit history :D