From 59af85b311e7c5669d9f66f6b5e872617d82e932 Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Sun, 1 Jan 2023 20:49:22 -0500 Subject: [PATCH 01/20] qml: add makefile for qmltest target --- src/Makefile.qmltest.include | 47 ++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/Makefile.qmltest.include diff --git a/src/Makefile.qmltest.include b/src/Makefile.qmltest.include new file mode 100644 index 0000000000..259960e686 --- /dev/null +++ b/src/Makefile.qmltest.include @@ -0,0 +1,47 @@ +# Copyright (c) 2013-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. + +bin_PROGRAMS += qml/test/test_bitcoin-qt +TESTS += qml/test/test_bitcoin-qt + +TEST_QML_MOC_CPP = \ + qml/test/moc_onboardingtests.cpp + +TEST_QML_H = + +qml_test_test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \ + $(QT_INCLUDES) $(QT_TEST_INCLUDES) $(BOOST_CPPFLAGS) + +qml_test_test_bitcoin_qt_SOURCES = \ + init/bitcoin-qt.cpp \ + qml/test/onboardingtests.cpp \ + $(TEST_QML_H) + +nodist_qml_test_test_bitcoin_qt_SOURCES = $(TEST_QML_MOC_CPP) + +qml_test_test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_NODE) $(LIBTEST_UTIL) +if ENABLE_WALLET +qml_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_UTIL) $(LIBBITCOIN_WALLET) +endif +if ENABLE_ZMQ +qml_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) +endif +qml_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) \ + $(LIBMEMENV) $(QT_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) \ + $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(LIBSECP256K1) \ + $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(SQLITE_LIBS) +qml_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) +qml_test_test_bitcoin_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) + +CLEAN_BITCOIN_QML_TEST = $(TEST_QML_MOC_CPP) qml/test/*.gcda qml/test/*.gcno + +CLEANFILES += $(CLEAN_BITCOIN_QML_TEST) + +test_bitcoin_qt_qml : qml/test/test_bitcoin-qt-qml$(EXEEXT) + +test_bitcoin_qt_qml_check : qt/test/test_bitcoin-qt-qml$(EXEEXT) FORCE + $(MAKE) check-TESTS TESTS=$^ + +test_bitcoin_qt_qml_clean: FORCE + rm -f $(CLEAN_BITCOIN_QML_TEST) $(qml_test_test_bitcoin_qt_OBJECTS) From 3e229de2128792598e09ac3454dd0edf7d20c24a Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Sun, 1 Jan 2023 20:49:45 -0500 Subject: [PATCH 02/20] qml: add test harness for onboarding qml tests --- src/qml/test/onboardingtests.cpp | 2 ++ src/qml/test/onboardingtests.h | 19 +++++++++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 src/qml/test/onboardingtests.cpp create mode 100644 src/qml/test/onboardingtests.h diff --git a/src/qml/test/onboardingtests.cpp b/src/qml/test/onboardingtests.cpp new file mode 100644 index 0000000000..35cd330ba3 --- /dev/null +++ b/src/qml/test/onboardingtests.cpp @@ -0,0 +1,2 @@ +#include +QUICK_TEST_MAIN(onboarding) diff --git a/src/qml/test/onboardingtests.h b/src/qml/test/onboardingtests.h new file mode 100644 index 0000000000..e2244499b1 --- /dev/null +++ b/src/qml/test/onboardingtests.h @@ -0,0 +1,19 @@ +// Copyright (c) 2014-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 +#include + +class Setup : public QObject +{ + Q_OBJECT + +public: + Setup(); + ~Setup() = default; + +public Q_SLOTS: + void qmlEngineAvailable(QQmlEngine * engine); +}; + From 6096e621b1397a4f29102b5bd23dba6d9cbd35e9 Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Wed, 4 Jan 2023 14:58:03 -0500 Subject: [PATCH 03/20] qml: add QtQuickTest library to qmltest target --- build-aux/m4/bitcoin_qt.m4 | 5 +++++ src/Makefile.am | 1 + src/Makefile.qmltest.include | 16 ++-------------- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/build-aux/m4/bitcoin_qt.m4 b/build-aux/m4/bitcoin_qt.m4 index 2d56708716..4d644ea14b 100644 --- a/build-aux/m4/bitcoin_qt.m4 +++ b/build-aux/m4/bitcoin_qt.m4 @@ -481,6 +481,11 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS],[ PKG_CHECK_MODULES([QT_QUICKCONTROLS], [${qt_lib_prefix}QuickControls2${qt_lib_suffix} $qt_version], [QT_INCLUDES="$QT_QUICKCONTROLS_CFLAGS $QT_INCLUDES" QT_LIBS="$QT_QUICKCONTROLS_LIBS $QT_LIBS"], [BITCOIN_QT_FAIL([${qt_lib_prefix}QuickControls2${qt_lib_suffix} $qt_version not found])]) ]) + BITCOIN_QT_CHECK([ + PKG_CHECK_MODULES([QT_QUICKTEST], [${qt_lib_prefix}QuickTest${qt_lib_suffix} $qt_version], [QT_INCLUDES="$QT_QUICKTEST_CFLAGS $QT_INCLUDES" QT_LIBS="$QT_QUICKTEST_LIBS $QT_LIBS"], + [BITCOIN_QT_FAIL([${qt_lib_prefix}QuickTest${qt_lib_suffix} $qt_version not found])]) + ]) + AC_DEFINE([USE_QML], [1], [Define to 1 to use QML-based GUI]) fi ]) diff --git a/src/Makefile.am b/src/Makefile.am index feed4a0061..789f315ad2 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1141,6 +1141,7 @@ endif if ENABLE_QT include Makefile.qt.include +include Makefile.qmltest.include endif if ENABLE_QT_TESTS diff --git a/src/Makefile.qmltest.include b/src/Makefile.qmltest.include index 259960e686..9b9d18cdc5 100644 --- a/src/Makefile.qmltest.include +++ b/src/Makefile.qmltest.include @@ -5,8 +5,7 @@ bin_PROGRAMS += qml/test/test_bitcoin-qt TESTS += qml/test/test_bitcoin-qt -TEST_QML_MOC_CPP = \ - qml/test/moc_onboardingtests.cpp +TEST_QML_MOC_CPP = TEST_QML_H = @@ -14,23 +13,12 @@ qml_test_test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN $(QT_INCLUDES) $(QT_TEST_INCLUDES) $(BOOST_CPPFLAGS) qml_test_test_bitcoin_qt_SOURCES = \ - init/bitcoin-qt.cpp \ qml/test/onboardingtests.cpp \ $(TEST_QML_H) nodist_qml_test_test_bitcoin_qt_SOURCES = $(TEST_QML_MOC_CPP) -qml_test_test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_NODE) $(LIBTEST_UTIL) -if ENABLE_WALLET -qml_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_UTIL) $(LIBBITCOIN_WALLET) -endif -if ENABLE_ZMQ -qml_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_ZMQ) $(ZMQ_LIBS) -endif -qml_test_test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBBITCOIN_UTIL) $(LIBBITCOIN_CONSENSUS) $(LIBBITCOIN_CRYPTO) $(LIBUNIVALUE) $(LIBLEVELDB) \ - $(LIBMEMENV) $(QT_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) \ - $(QR_LIBS) $(BDB_LIBS) $(MINIUPNPC_LIBS) $(NATPMP_LIBS) $(LIBSECP256K1) \ - $(EVENT_PTHREADS_LIBS) $(EVENT_LIBS) $(SQLITE_LIBS) +qml_test_test_bitcoin_qt_LDADD = $(QT_QUICKTEST_LIBS) qml_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) qml_test_test_bitcoin_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) From 325808ce6fdf4fc6d4a81c21edab8bb012138f98 Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Sun, 8 Jan 2023 18:27:46 -0500 Subject: [PATCH 04/20] qml: add first qml testcase --- src/qml/test/tst_onboarding.qml | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 src/qml/test/tst_onboarding.qml diff --git a/src/qml/test/tst_onboarding.qml b/src/qml/test/tst_onboarding.qml new file mode 100644 index 0000000000..f16165846d --- /dev/null +++ b/src/qml/test/tst_onboarding.qml @@ -0,0 +1,24 @@ +import "../controls" +import "../controls" +import "../pages/onboarding" +import QtQuick 2.15 +import QtTest 1.15 + +Rectangle { + id: root + width: 640 + height: 665 + color: Theme.color.background + + OnboardingCover {} + + TestCase { + id: onboardingFlow + when: windowShown + + function test_maths() { + var image = grabImage(root) + image.save("./output.png") + } + } +} From 6186017bb5e669bdc093184ebc84a5dcba2a236f Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Sun, 8 Jan 2023 19:10:28 -0500 Subject: [PATCH 05/20] qml: add imageprovider to test setup --- src/Makefile.qmltest.include | 14 ++-- src/qml/test/imageprovider.cpp | 110 +++++++++++++++++++++++++++++++ src/qml/test/imageprovider.h | 25 +++++++ src/qml/test/onboardingtests.cpp | 16 ++++- 4 files changed, 159 insertions(+), 6 deletions(-) create mode 100644 src/qml/test/imageprovider.cpp create mode 100644 src/qml/test/imageprovider.h diff --git a/src/Makefile.qmltest.include b/src/Makefile.qmltest.include index 9b9d18cdc5..9f2967ce5a 100644 --- a/src/Makefile.qmltest.include +++ b/src/Makefile.qmltest.include @@ -5,20 +5,24 @@ bin_PROGRAMS += qml/test/test_bitcoin-qt TESTS += qml/test/test_bitcoin-qt -TEST_QML_MOC_CPP = +TEST_QML_MOC_CPP = qml/test/moc_onboardingtests.cpp -TEST_QML_H = +TEST_QML_H = qml/test/onboardingtests.h qml/test/imageprovider.h qml_test_test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \ - $(QT_INCLUDES) $(QT_TEST_INCLUDES) $(BOOST_CPPFLAGS) + $(QT_INCLUDES) $(QT_TEST_INCLUDES) $(QT_QUICKTEST_INCLUDES) $(BOOST_CPPFLAGS) qml_test_test_bitcoin_qt_SOURCES = \ + $(TEST_QML_MOC_CPP) \ qml/test/onboardingtests.cpp \ + qml/qrc_bitcoin.cpp \ + qml/bitcoin_qml.qrc \ + qml/test/imageprovider.cpp \ $(TEST_QML_H) -nodist_qml_test_test_bitcoin_qt_SOURCES = $(TEST_QML_MOC_CPP) +nodist_qml_test_test_bitcoin_qt_SOURCES = $(TEST_QML_MOC_CPP) $(QML_QRC_CPP) -qml_test_test_bitcoin_qt_LDADD = $(QT_QUICKTEST_LIBS) +qml_test_test_bitcoin_qt_LDADD = $(QT_QUICKTEST_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) qml_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) qml_test_test_bitcoin_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) diff --git a/src/qml/test/imageprovider.cpp b/src/qml/test/imageprovider.cpp new file mode 100644 index 0000000000..37a2aaf6cb --- /dev/null +++ b/src/qml/test/imageprovider.cpp @@ -0,0 +1,110 @@ +// 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 + +#include +#include +#include +#include +#include + +TestImageProvider::TestImageProvider() + : QQuickImageProvider{QQuickImageProvider::Pixmap} +{ +} + +QPixmap TestImageProvider::requestPixmap(const QString& id, QSize* size, const QSize& requested_size) +{ + if (!size || !requested_size.isValid()) { + return {}; + } + + if (id == "arrow-down") { + *size = requested_size; + return QIcon(":/icons/arrow-down").pixmap(requested_size); + } + + if (id == "arrow-up") { + *size = requested_size; + return QIcon(":/icons/arrow-up").pixmap(requested_size); + } + + if (id == "bitcoin-circle") { + *size = requested_size; + return QIcon(":/icons/bitcoin-circle").pixmap(requested_size); + } + + if (id == "blocktime-dark") { + *size = requested_size; + return QIcon(":/icons/blocktime-dark").pixmap(requested_size); + } + + if (id == "blocktime-light") { + *size = requested_size; + return QIcon(":/icons/blocktime-light").pixmap(requested_size); + } + + if (id == "app") { + *size = requested_size; + return QIcon(":/icons/bitcoin").pixmap(requested_size); + } + + if (id == "caret-left") { + *size = requested_size; + return QIcon(":/icons/caret-left").pixmap(requested_size); + } + + if (id == "caret-right") { + *size = requested_size; + return QIcon(":/icons/caret-right").pixmap(requested_size); + } + + if (id == "check") { + *size = requested_size; + return QIcon(":/icons/check").pixmap(requested_size); + } + + if (id == "cross") { + *size = requested_size; + return QIcon(":/icons/cross").pixmap(requested_size); + } + + if (id == "export") { + *size = requested_size; + return QIcon(":/icons/export").pixmap(requested_size); + } + + if (id == "gear") { + *size = requested_size; + return QIcon(":/icons/gear").pixmap(requested_size); + } + + if (id == "info") { + *size = requested_size; + return QIcon(":/icons/info").pixmap(requested_size); + } + + if (id == "network-dark") { + *size = requested_size; + return QIcon(":/icons/network-dark").pixmap(requested_size); + } + + if (id == "network-light") { + *size = requested_size; + return QIcon(":/icons/network-light").pixmap(requested_size); + } + + if (id == "storage-dark") { + *size = requested_size; + return QIcon(":/icons/storage-dark").pixmap(requested_size); + } + + if (id == "storage-light") { + *size = requested_size; + return QIcon(":/icons/storage-light").pixmap(requested_size); + } + + return {}; +} diff --git a/src/qml/test/imageprovider.h b/src/qml/test/imageprovider.h new file mode 100644 index 0000000000..4ff4140d81 --- /dev/null +++ b/src/qml/test/imageprovider.h @@ -0,0 +1,25 @@ +// Copyright (c) 2021 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#ifndef BITCOIN_QML_TEST_IMAGEPROVIDER_H +#define BITCOIN_QML_TEST_IMAGEPROVIDER_H + +#include +#include + +QT_BEGIN_NAMESPACE +class QSize; +class QString; +QT_END_NAMESPACE + +class TestImageProvider : public QQuickImageProvider +{ +public: + explicit TestImageProvider(); + + QPixmap requestPixmap(const QString& id, QSize* size, const QSize& requested_size) override; + +}; + +#endif // BITCOIN_QML_IMAGEPROVIDER_H diff --git a/src/qml/test/onboardingtests.cpp b/src/qml/test/onboardingtests.cpp index 35cd330ba3..82ae17661b 100644 --- a/src/qml/test/onboardingtests.cpp +++ b/src/qml/test/onboardingtests.cpp @@ -1,2 +1,16 @@ #include -QUICK_TEST_MAIN(onboarding) +#include +#include +#include +#include +#include + +Setup::Setup() +{ +} + +void Setup::qmlEngineAvailable(QQmlEngine * engine) { + engine->addImageProvider(QStringLiteral("images"), new TestImageProvider()); +} + +QUICK_TEST_MAIN_WITH_SETUP(onboarding, Setup) From 0cf1f3d3f22a5761415db1549406fb92a60c069a Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Sun, 8 Jan 2023 20:24:44 -0500 Subject: [PATCH 06/20] qml: remove double linkage in Makefile.qmltest.include --- src/Makefile.qmltest.include | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Makefile.qmltest.include b/src/Makefile.qmltest.include index 9f2967ce5a..d8fe413017 100644 --- a/src/Makefile.qmltest.include +++ b/src/Makefile.qmltest.include @@ -13,9 +13,7 @@ qml_test_test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN $(QT_INCLUDES) $(QT_TEST_INCLUDES) $(QT_QUICKTEST_INCLUDES) $(BOOST_CPPFLAGS) qml_test_test_bitcoin_qt_SOURCES = \ - $(TEST_QML_MOC_CPP) \ qml/test/onboardingtests.cpp \ - qml/qrc_bitcoin.cpp \ qml/bitcoin_qml.qrc \ qml/test/imageprovider.cpp \ $(TEST_QML_H) From c8b15a41395ef4e49562d36d51e2745c97d2436c Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Sun, 8 Jan 2023 20:25:50 -0500 Subject: [PATCH 07/20] qml/test: have OnboardingCover fill parent --- src/qml/test/tst_onboarding.qml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/qml/test/tst_onboarding.qml b/src/qml/test/tst_onboarding.qml index f16165846d..350bfbb2ad 100644 --- a/src/qml/test/tst_onboarding.qml +++ b/src/qml/test/tst_onboarding.qml @@ -10,7 +10,9 @@ Rectangle { height: 665 color: Theme.color.background - OnboardingCover {} + OnboardingCover { + anchors.fill: parent + } TestCase { id: onboardingFlow From a75059ee7ca1572a6f640da48f2b012ce583661a Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Sun, 8 Jan 2023 20:29:01 -0500 Subject: [PATCH 08/20] qml/test: add fake qt.bitcoincore.org module --- src/qml/test/org/bitcoincore/qt/AppMode.qml | 12 ++++++++++++ src/qml/test/org/bitcoincore/qt/qmldir | 2 ++ 2 files changed, 14 insertions(+) create mode 100644 src/qml/test/org/bitcoincore/qt/AppMode.qml create mode 100644 src/qml/test/org/bitcoincore/qt/qmldir diff --git a/src/qml/test/org/bitcoincore/qt/AppMode.qml b/src/qml/test/org/bitcoincore/qt/AppMode.qml new file mode 100644 index 0000000000..00d0d57a95 --- /dev/null +++ b/src/qml/test/org/bitcoincore/qt/AppMode.qml @@ -0,0 +1,12 @@ +pragma Singleton +import QtQuick 2.15 + +Item { + property bool isDesktop: true + property bool isMobile: false + enum Mode { + DESKTOP, + MOBILE + } + property string state: "MOBILE" +} diff --git a/src/qml/test/org/bitcoincore/qt/qmldir b/src/qml/test/org/bitcoincore/qt/qmldir new file mode 100644 index 0000000000..56f01a045b --- /dev/null +++ b/src/qml/test/org/bitcoincore/qt/qmldir @@ -0,0 +1,2 @@ +module org.bitcoincore.qt +singleton AppMode 1.0 AppMode.qml From 8401964fe790a0c1ef4fbf390269959eaae702f8 Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Mon, 9 Jan 2023 22:25:48 -0500 Subject: [PATCH 09/20] qml: extract OnboardingWizard from main.qml --- src/Makefile.qt.include | 1 + src/qml/bitcoin_qml.qrc | 1 + src/qml/pages/main.qml | 13 +------------ src/qml/pages/onboarding/OnboardingWizard.qml | 19 +++++++++++++++++++ 4 files changed, 22 insertions(+), 12 deletions(-) create mode 100644 src/qml/pages/onboarding/OnboardingWizard.qml diff --git a/src/Makefile.qt.include b/src/Makefile.qt.include index ba032ee58f..3d6c148c89 100644 --- a/src/Makefile.qt.include +++ b/src/Makefile.qt.include @@ -390,6 +390,7 @@ QML_RES_QML = \ qml/pages/onboarding/OnboardingStorageAmount.qml \ qml/pages/onboarding/OnboardingStorageLocation.qml \ qml/pages/onboarding/OnboardingStrengthen.qml \ + qml/pages/onboarding/OnboardingWizard.qml \ qml/pages/settings/SettingsAbout.qml \ qml/pages/settings/SettingsBlockClockDisplayMode.qml \ qml/pages/settings/SettingsConnection.qml \ diff --git a/src/qml/bitcoin_qml.qrc b/src/qml/bitcoin_qml.qrc index 44e0448884..d2caac3cf7 100644 --- a/src/qml/bitcoin_qml.qrc +++ b/src/qml/bitcoin_qml.qrc @@ -51,6 +51,7 @@ pages/onboarding/OnboardingStorageAmount.qml pages/onboarding/OnboardingStorageLocation.qml pages/onboarding/OnboardingStrengthen.qml + pages/onboarding/OnboardingWizard.qml pages/settings/SettingsAbout.qml pages/settings/SettingsBlockClockDisplayMode.qml pages/settings/SettingsConnection.qml diff --git a/src/qml/pages/main.qml b/src/qml/pages/main.qml index 99f84fe35c..e2a89b73c8 100644 --- a/src/qml/pages/main.qml +++ b/src/qml/pages/main.qml @@ -54,18 +54,7 @@ ApplicationWindow { Component { id: onboardingWizard - SwipeView { - id: swipeView - property bool finished: false - interactive: false - - OnboardingCover {} - OnboardingStrengthen {} - OnboardingBlockclock {} - OnboardingStorageLocation {} - OnboardingStorageAmount {} - OnboardingConnection {} - + OnboardingWizard { onFinishedChanged: main.push(node) } } diff --git a/src/qml/pages/onboarding/OnboardingWizard.qml b/src/qml/pages/onboarding/OnboardingWizard.qml new file mode 100644 index 0000000000..ac07332a61 --- /dev/null +++ b/src/qml/pages/onboarding/OnboardingWizard.qml @@ -0,0 +1,19 @@ +// 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. + +import QtQuick 2.15 +import QtQuick.Controls 2.15 + +SwipeView { + id: swipeView + property bool finished: false + interactive: false + + OnboardingCover {} + OnboardingStrengthen {} + OnboardingBlockclock {} + OnboardingStorageLocation {} + OnboardingStorageAmount {} + OnboardingConnection {} +} From eb2eb8dea1449d461e65a75584587b049c2236c3 Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Tue, 10 Jan 2023 23:58:50 -0500 Subject: [PATCH 10/20] qml/test: add test_all_continue_buttons --- src/qml/controls/ContinueButton.qml | 1 + .../pages/onboarding/OnboardingBlockclock.qml | 1 + .../pages/onboarding/OnboardingConnection.qml | 1 + src/qml/pages/onboarding/OnboardingCover.qml | 1 + .../onboarding/OnboardingStorageAmount.qml | 1 + .../onboarding/OnboardingStorageLocation.qml | 1 + .../pages/onboarding/OnboardingStrengthen.qml | 1 + src/qml/test/tst_onboarding.qml | 50 ++++++++++++++++--- 8 files changed, 49 insertions(+), 8 deletions(-) diff --git a/src/qml/controls/ContinueButton.qml b/src/qml/controls/ContinueButton.qml index dd1fa76bab..1bfaf1bc92 100644 --- a/src/qml/controls/ContinueButton.qml +++ b/src/qml/controls/ContinueButton.qml @@ -9,6 +9,7 @@ import org.bitcoincore.qt 1.0 Button { id: root hoverEnabled: AppMode.isDesktop + objectName: "continueButton" contentItem: CoreText { text: parent.text bold: true diff --git a/src/qml/pages/onboarding/OnboardingBlockclock.qml b/src/qml/pages/onboarding/OnboardingBlockclock.qml index 91950fa9c3..1f99a34caa 100644 --- a/src/qml/pages/onboarding/OnboardingBlockclock.qml +++ b/src/qml/pages/onboarding/OnboardingBlockclock.qml @@ -8,6 +8,7 @@ import QtQuick.Layouts 1.15 import "../../controls" InformationPage { + objectName: "onboardingBlockClock" navLeftDetail: NavButton { iconSource: "image://images/caret-left" text: qsTr("Back") diff --git a/src/qml/pages/onboarding/OnboardingConnection.qml b/src/qml/pages/onboarding/OnboardingConnection.qml index d5c5b5875c..3cc834653d 100644 --- a/src/qml/pages/onboarding/OnboardingConnection.qml +++ b/src/qml/pages/onboarding/OnboardingConnection.qml @@ -11,6 +11,7 @@ import "../settings" Page { background: null + objectName: "onboardingConnection" clip: true SwipeView { id: connections diff --git a/src/qml/pages/onboarding/OnboardingCover.qml b/src/qml/pages/onboarding/OnboardingCover.qml index 2a7dcbd237..48151d2340 100644 --- a/src/qml/pages/onboarding/OnboardingCover.qml +++ b/src/qml/pages/onboarding/OnboardingCover.qml @@ -12,6 +12,7 @@ import "../settings" Page { background: null clip: true + objectName: "onboardingCover" SwipeView { id: introductions anchors.fill: parent diff --git a/src/qml/pages/onboarding/OnboardingStorageAmount.qml b/src/qml/pages/onboarding/OnboardingStorageAmount.qml index e4cdf06e20..04d0afa8fb 100644 --- a/src/qml/pages/onboarding/OnboardingStorageAmount.qml +++ b/src/qml/pages/onboarding/OnboardingStorageAmount.qml @@ -10,6 +10,7 @@ import "../../components" import "../settings" Page { + objectName: "onboardingStorageAmount" background: null clip: true SwipeView { diff --git a/src/qml/pages/onboarding/OnboardingStorageLocation.qml b/src/qml/pages/onboarding/OnboardingStorageLocation.qml index b2c3aa1e00..1d2e7d7088 100644 --- a/src/qml/pages/onboarding/OnboardingStorageLocation.qml +++ b/src/qml/pages/onboarding/OnboardingStorageLocation.qml @@ -10,6 +10,7 @@ import "../../controls" import "../../components" InformationPage { + objectName: "onboardingStorageLocation" navLeftDetail: NavButton { iconSource: "image://images/caret-left" text: qsTr("Back") diff --git a/src/qml/pages/onboarding/OnboardingStrengthen.qml b/src/qml/pages/onboarding/OnboardingStrengthen.qml index df4b803c71..27a4a6704a 100644 --- a/src/qml/pages/onboarding/OnboardingStrengthen.qml +++ b/src/qml/pages/onboarding/OnboardingStrengthen.qml @@ -8,6 +8,7 @@ import QtQuick.Layouts 1.15 import "../../controls" InformationPage { + objectName: "onboardingStrengthen" navLeftDetail: NavButton { iconSource: "image://images/caret-left" text: qsTr("Back") diff --git a/src/qml/test/tst_onboarding.qml b/src/qml/test/tst_onboarding.qml index 350bfbb2ad..3bafb9958a 100644 --- a/src/qml/test/tst_onboarding.qml +++ b/src/qml/test/tst_onboarding.qml @@ -1,8 +1,7 @@ -import "../controls" -import "../controls" -import "../pages/onboarding" import QtQuick 2.15 import QtTest 1.15 +import "../controls" +import "../pages/onboarding" Rectangle { id: root @@ -10,17 +9,52 @@ Rectangle { height: 665 color: Theme.color.background - OnboardingCover { + OnboardingWizard { + id: onboardingWizard anchors.fill: parent } TestCase { id: onboardingFlow when: windowShown - - function test_maths() { - var image = grabImage(root) - image.save("./output.png") + + function test_all_continue_buttons() { + verify(onboardingWizard.currentIndex == 0) + + var cover = findChild(onboardingWizard, "onboardingCover") + verify(cover, onboardingWizard.currentItem) + mouseClick(findChild(cover, "continueButton")) + verify(onboardingWizard.currentIndex == 1) + wait(200) + + var strengthen = findChild(onboardingWizard, "onboardingStrengthen") + verify(strengthen, onboardingWizard.currentItem) + mouseClick(findChild(strengthen, "continueButton")) + verify(onboardingWizard.currentIndex == 2) + wait(200) + + var blockClock = findChild(onboardingWizard, "onboardingBlockClock") + verify(blockClock, onboardingWizard.currentItem) + mouseClick(findChild(blockClock, "continueButton")) + verify(onboardingWizard.currentIndex == 3) + wait(200) + + var storageLocation = findChild(onboardingWizard, "onboardingStorageLocation") + verify(storageLocation, onboardingWizard.currentItem) + mouseClick(findChild(storageLocation, "continueButton")) + verify(onboardingWizard.currentIndex == 4) + wait(200) + + var storageAmount = findChild(onboardingWizard, "onboardingStorageAmount") + verify(storageAmount, onboardingWizard.currentItem) + mouseClick(findChild(storageAmount, "continueButton")) + verify(onboardingWizard.currentIndex == 5) + wait(200) + + var connection = findChild(onboardingWizard, "onboardingConnection") + verify(connection, onboardingWizard.currentItem) + mouseClick(findChild(connection, "continueButton")) + verify(onboardingWizard.finished) } } } From 2ef647994bc2a4c0714ff5c9c0a2b29ed30da3dd Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Thu, 12 Jan 2023 20:48:18 -0500 Subject: [PATCH 11/20] qmltest: configure to only compile with qml and tests enabled --- build-aux/m4/bitcoin_qt.m4 | 7 +++++-- configure.ac | 12 +++++++++++- src/Makefile.am | 5 ++++- src/Makefile.qmltest.include | 4 ++-- 4 files changed, 22 insertions(+), 6 deletions(-) diff --git a/build-aux/m4/bitcoin_qt.m4 b/build-aux/m4/bitcoin_qt.m4 index 4d644ea14b..52174edb8c 100644 --- a/build-aux/m4/bitcoin_qt.m4 +++ b/build-aux/m4/bitcoin_qt.m4 @@ -320,6 +320,10 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[ if test "$have_qt_test" = "no"; then bitcoin_enable_qt_test=no fi + bitcoin_enable_qml_test=yes + if test "$have_qml_test" = "no"; then + bitcoin_enable_qml_test=no + fi bitcoin_enable_qt_dbus=no if test "$use_dbus" != "no" && test "$have_qt_dbus" = "yes"; then bitcoin_enable_qt_dbus=yes @@ -482,8 +486,7 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS],[ [BITCOIN_QT_FAIL([${qt_lib_prefix}QuickControls2${qt_lib_suffix} $qt_version not found])]) ]) BITCOIN_QT_CHECK([ - PKG_CHECK_MODULES([QT_QUICKTEST], [${qt_lib_prefix}QuickTest${qt_lib_suffix} $qt_version], [QT_INCLUDES="$QT_QUICKTEST_CFLAGS $QT_INCLUDES" QT_LIBS="$QT_QUICKTEST_LIBS $QT_LIBS"], - [BITCOIN_QT_FAIL([${qt_lib_prefix}QuickTest${qt_lib_suffix} $qt_version not found])]) + PKG_CHECK_MODULES([QT_QUICKTEST], [${qt_lib_prefix}QuickTest${qt_lib_suffix} $qt_version], [QT_QMLTEST_INCLUDES="$QT_QUICKTEST_CFLAGS"; have_quick_test=yes],[have_quick_test=no]) ]) AC_DEFINE([USE_QML], [1], [Define to 1 to use QML-based GUI]) diff --git a/configure.ac b/configure.ac index c26c04cf79..319a6de8d0 100644 --- a/configure.ac +++ b/configure.ac @@ -1764,8 +1764,9 @@ fi dnl these are only used when qt is enabled BUILD_TEST_QT="" +BUILD_TEST_QML="" if test "$use_qml" != "no"; then - use_gui_tests=no + bitcoin_enable_qt_test=no fi if test "$bitcoin_enable_qt" != "no"; then dnl enable dbus support @@ -1801,6 +1802,14 @@ if test "$bitcoin_enable_qt" != "no"; then else AC_MSG_RESULT([no]) fi + + AC_MSG_CHECKING([whether to build qml/test_bitcoin-qt]) + if test "$use_gui_tests$bitcoin_enable_qml_test" = "yesyes"; then + AC_MSG_RESULT([yes]) + BUILD_TEST_QML="yes" + else + AC_MSG_RESULT([no]) + fi fi AC_MSG_CHECKING([whether to build test_bitcoin]) @@ -1840,6 +1849,7 @@ AM_CONDITIONAL([ENABLE_FUZZ], [test "$enable_fuzz" = "yes"]) AM_CONDITIONAL([ENABLE_FUZZ_BINARY], [test "$enable_fuzz_binary" = "yes"]) AM_CONDITIONAL([ENABLE_QT], [test "$bitcoin_enable_qt" = "yes"]) AM_CONDITIONAL([ENABLE_QT_TESTS], [test "$BUILD_TEST_QT" = "yes"]) +AM_CONDITIONAL([ENABLE_QML_TESTS], [test "$BUILD_TEST_QML" = "yes"]) AM_CONDITIONAL([ENABLE_BENCH], [test "$use_bench" = "yes"]) AM_CONDITIONAL([USE_QRCODE], [test "$use_qr" = "yes"]) AM_CONDITIONAL([USE_LCOV], [test "$use_lcov" = "yes"]) diff --git a/src/Makefile.am b/src/Makefile.am index 789f315ad2..e3cbd90046 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -1141,11 +1141,14 @@ endif if ENABLE_QT include Makefile.qt.include -include Makefile.qmltest.include endif if ENABLE_QT_TESTS include Makefile.qttest.include endif +if ENABLE_QML_TESTS +include Makefile.qmltest.include +endif + include Makefile.univalue.include diff --git a/src/Makefile.qmltest.include b/src/Makefile.qmltest.include index d8fe413017..c6d53cc119 100644 --- a/src/Makefile.qmltest.include +++ b/src/Makefile.qmltest.include @@ -10,7 +10,7 @@ TEST_QML_MOC_CPP = qml/test/moc_onboardingtests.cpp TEST_QML_H = qml/test/onboardingtests.h qml/test/imageprovider.h qml_test_test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \ - $(QT_INCLUDES) $(QT_TEST_INCLUDES) $(QT_QUICKTEST_INCLUDES) $(BOOST_CPPFLAGS) + $(QT_INCLUDES) $(QT_TEST_INCLUDES) $(QT_QUICKTEST_INCLUDES) $(BOOST_CPPFLAGS) $(QT_QUICKTEST_CFLAGS) qml_test_test_bitcoin_qt_SOURCES = \ qml/test/onboardingtests.cpp \ @@ -24,7 +24,7 @@ qml_test_test_bitcoin_qt_LDADD = $(QT_QUICKTEST_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) qml_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) qml_test_test_bitcoin_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) -CLEAN_BITCOIN_QML_TEST = $(TEST_QML_MOC_CPP) qml/test/*.gcda qml/test/*.gcno +CLEAN_BITCOIN_QML_TEST = $(TEST_QML_MOC_CPP) CLEANFILES += $(CLEAN_BITCOIN_QML_TEST) From 332ed16cc66c03fc4fae9ccf489168184bd80cc2 Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Thu, 12 Jan 2023 21:49:12 -0500 Subject: [PATCH 12/20] qmltest: rename testimageprovider --- src/Makefile.qmltest.include | 4 ++-- src/qml/test/onboardingtests.cpp | 3 +-- src/qml/test/{imageprovider.cpp => testimageprovider.cpp} | 2 +- src/qml/test/{imageprovider.h => testimageprovider.h} | 0 4 files changed, 4 insertions(+), 5 deletions(-) rename src/qml/test/{imageprovider.cpp => testimageprovider.cpp} (98%) rename src/qml/test/{imageprovider.h => testimageprovider.h} (100%) diff --git a/src/Makefile.qmltest.include b/src/Makefile.qmltest.include index c6d53cc119..adff402078 100644 --- a/src/Makefile.qmltest.include +++ b/src/Makefile.qmltest.include @@ -7,7 +7,7 @@ TESTS += qml/test/test_bitcoin-qt TEST_QML_MOC_CPP = qml/test/moc_onboardingtests.cpp -TEST_QML_H = qml/test/onboardingtests.h qml/test/imageprovider.h +TEST_QML_H = qml/test/onboardingtests.h qml/test/testimageprovider.h qml_test_test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \ $(QT_INCLUDES) $(QT_TEST_INCLUDES) $(QT_QUICKTEST_INCLUDES) $(BOOST_CPPFLAGS) $(QT_QUICKTEST_CFLAGS) @@ -15,7 +15,7 @@ qml_test_test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN qml_test_test_bitcoin_qt_SOURCES = \ qml/test/onboardingtests.cpp \ qml/bitcoin_qml.qrc \ - qml/test/imageprovider.cpp \ + qml/test/testimageprovider.cpp \ $(TEST_QML_H) nodist_qml_test_test_bitcoin_qt_SOURCES = $(TEST_QML_MOC_CPP) $(QML_QRC_CPP) diff --git a/src/qml/test/onboardingtests.cpp b/src/qml/test/onboardingtests.cpp index 82ae17661b..8e464dae93 100644 --- a/src/qml/test/onboardingtests.cpp +++ b/src/qml/test/onboardingtests.cpp @@ -1,9 +1,8 @@ #include #include #include -#include +#include #include -#include Setup::Setup() { diff --git a/src/qml/test/imageprovider.cpp b/src/qml/test/testimageprovider.cpp similarity index 98% rename from src/qml/test/imageprovider.cpp rename to src/qml/test/testimageprovider.cpp index 37a2aaf6cb..484450ffcd 100644 --- a/src/qml/test/imageprovider.cpp +++ b/src/qml/test/testimageprovider.cpp @@ -2,7 +2,7 @@ // Distributed under the MIT software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include +#include #include #include diff --git a/src/qml/test/imageprovider.h b/src/qml/test/testimageprovider.h similarity index 100% rename from src/qml/test/imageprovider.h rename to src/qml/test/testimageprovider.h From 3909a63d62a27ab43f64f7fa1525edf5a5e51a11 Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Fri, 13 Jan 2023 08:45:34 -0500 Subject: [PATCH 13/20] qml/test: add include guards to headers --- src/qml/test/onboardingtests.cpp | 3 +++ src/qml/test/onboardingtests.h | 7 +++++-- src/qml/test/testimageprovider.h | 8 ++++---- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/src/qml/test/onboardingtests.cpp b/src/qml/test/onboardingtests.cpp index 8e464dae93..f2f172656e 100644 --- a/src/qml/test/onboardingtests.cpp +++ b/src/qml/test/onboardingtests.cpp @@ -1,3 +1,6 @@ +// 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 #include #include diff --git a/src/qml/test/onboardingtests.h b/src/qml/test/onboardingtests.h index e2244499b1..728d7a25b0 100644 --- a/src/qml/test/onboardingtests.h +++ b/src/qml/test/onboardingtests.h @@ -1,6 +1,8 @@ // Copyright (c) 2014-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. +#ifndef BITCOIN_QML_TEST_ONBOARDINGTESTS_H +#define BITCOIN_QML_TEST_ONBOARDINGTESTS_H #include #include @@ -10,10 +12,11 @@ class Setup : public QObject Q_OBJECT public: - Setup(); + Setup(); ~Setup() = default; public Q_SLOTS: - void qmlEngineAvailable(QQmlEngine * engine); + void qmlEngineAvailable(QQmlEngine * engine); }; +#endif // BITCOIN_QML_TEST_ONBOARDINGTESTS_H diff --git a/src/qml/test/testimageprovider.h b/src/qml/test/testimageprovider.h index 4ff4140d81..922a0ef891 100644 --- a/src/qml/test/testimageprovider.h +++ b/src/qml/test/testimageprovider.h @@ -1,9 +1,9 @@ -// Copyright (c) 2021 The Bitcoin Core developers +// 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. -#ifndef BITCOIN_QML_TEST_IMAGEPROVIDER_H -#define BITCOIN_QML_TEST_IMAGEPROVIDER_H +#ifndef BITCOIN_QML_TEST_TESTIMAGEPROVIDER_H +#define BITCOIN_QML_TEST_TESTIMAGEPROVIDER_H #include #include @@ -22,4 +22,4 @@ class TestImageProvider : public QQuickImageProvider }; -#endif // BITCOIN_QML_IMAGEPROVIDER_H +#endif // BITCOIN_QML_TEST_TESTIMAGEPROVIDER_H From dcfba819cd58a0e5523fa697661707cbbecfbff4 Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Fri, 13 Jan 2023 09:34:20 -0500 Subject: [PATCH 14/20] gitignore: add output from qmltest --- .gitignore | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.gitignore b/.gitignore index 6b57d56ca2..273f0b183c 100644 --- a/.gitignore +++ b/.gitignore @@ -14,6 +14,7 @@ src/bitcoin-wallet src/test/fuzz/fuzz src/test/test_bitcoin src/qt/test/test_bitcoin-qt +src/qml/test/test_bitcoin-qt # autoreconf Makefile.in @@ -52,6 +53,7 @@ src/qml/models/moc_*.cpp src/qt/forms/ui_*.h src/qt/test/moc*.cpp +src/qml/test/moc*.cpp src/qt/bitcoin-qt.config src/qt/bitcoin-qt.creator From 953ce9a31e643e9cc1f3bfea84021c3b8fab7549 Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Fri, 13 Jan 2023 13:01:54 -0500 Subject: [PATCH 15/20] qmltest: don't compile if qml isn't enabled --- configure.ac | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 319a6de8d0..eec43d30a7 100644 --- a/configure.ac +++ b/configure.ac @@ -1804,7 +1804,7 @@ if test "$bitcoin_enable_qt" != "no"; then fi AC_MSG_CHECKING([whether to build qml/test_bitcoin-qt]) - if test "$use_gui_tests$bitcoin_enable_qml_test" = "yesyes"; then + if test "$use_qml$use_gui_tests$bitcoin_enable_qml_test" = "yesyesyes"; then AC_MSG_RESULT([yes]) BUILD_TEST_QML="yes" else From ad9038f8801231e5b94938f54883c3aacecc4bbe Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Sat, 14 Jan 2023 14:19:51 -0500 Subject: [PATCH 16/20] qmltest: rename onboardingtests to setup --- src/Makefile.qmltest.include | 6 +++--- src/qml/test/{onboardingtests.cpp => setup.cpp} | 7 ++----- src/qml/test/{onboardingtests.h => setup.h} | 8 ++++---- 3 files changed, 9 insertions(+), 12 deletions(-) rename src/qml/test/{onboardingtests.cpp => setup.cpp} (89%) rename src/qml/test/{onboardingtests.h => setup.h} (72%) diff --git a/src/Makefile.qmltest.include b/src/Makefile.qmltest.include index adff402078..bada06caa1 100644 --- a/src/Makefile.qmltest.include +++ b/src/Makefile.qmltest.include @@ -5,15 +5,15 @@ bin_PROGRAMS += qml/test/test_bitcoin-qt TESTS += qml/test/test_bitcoin-qt -TEST_QML_MOC_CPP = qml/test/moc_onboardingtests.cpp +TEST_QML_MOC_CPP = qml/test/moc_setup.cpp -TEST_QML_H = qml/test/onboardingtests.h qml/test/testimageprovider.h +TEST_QML_H = qml/test/setup.h qml/test/testimageprovider.h qml_test_test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \ $(QT_INCLUDES) $(QT_TEST_INCLUDES) $(QT_QUICKTEST_INCLUDES) $(BOOST_CPPFLAGS) $(QT_QUICKTEST_CFLAGS) qml_test_test_bitcoin_qt_SOURCES = \ - qml/test/onboardingtests.cpp \ + qml/test/setup.cpp \ qml/bitcoin_qml.qrc \ qml/test/testimageprovider.cpp \ $(TEST_QML_H) diff --git a/src/qml/test/onboardingtests.cpp b/src/qml/test/setup.cpp similarity index 89% rename from src/qml/test/onboardingtests.cpp rename to src/qml/test/setup.cpp index f2f172656e..3de12a5ebc 100644 --- a/src/qml/test/onboardingtests.cpp +++ b/src/qml/test/setup.cpp @@ -1,15 +1,12 @@ // 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 + #include #include #include #include -#include - -Setup::Setup() -{ -} void Setup::qmlEngineAvailable(QQmlEngine * engine) { engine->addImageProvider(QStringLiteral("images"), new TestImageProvider()); diff --git a/src/qml/test/onboardingtests.h b/src/qml/test/setup.h similarity index 72% rename from src/qml/test/onboardingtests.h rename to src/qml/test/setup.h index 728d7a25b0..074a27f047 100644 --- a/src/qml/test/onboardingtests.h +++ b/src/qml/test/setup.h @@ -1,8 +1,8 @@ // Copyright (c) 2014-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. -#ifndef BITCOIN_QML_TEST_ONBOARDINGTESTS_H -#define BITCOIN_QML_TEST_ONBOARDINGTESTS_H +#ifndef BITCOIN_QML_TEST_SETUP_H +#define BITCOIN_QML_TEST_SETUP_H #include #include @@ -12,11 +12,11 @@ class Setup : public QObject Q_OBJECT public: - Setup(); + Setup() = default; ~Setup() = default; public Q_SLOTS: void qmlEngineAvailable(QQmlEngine * engine); }; -#endif // BITCOIN_QML_TEST_ONBOARDINGTESTS_H +#endif // BITCOIN_QML_TEST_SETUP_H From d41e3b3659d19de1ccd2d5568a1b7ff2a14e2997 Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Sat, 14 Jan 2023 15:03:05 -0500 Subject: [PATCH 17/20] qmltest: add/fix copyright comments --- src/Makefile.qmltest.include | 2 +- src/qml/test/org/bitcoincore/qt/AppMode.qml | 4 ++++ src/qml/test/org/bitcoincore/qt/qmldir | 4 ++++ src/qml/test/setup.h | 2 +- src/qml/test/tst_onboarding.qml | 4 ++++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/Makefile.qmltest.include b/src/Makefile.qmltest.include index bada06caa1..83c435840b 100644 --- a/src/Makefile.qmltest.include +++ b/src/Makefile.qmltest.include @@ -1,4 +1,4 @@ -# Copyright (c) 2013-2023 The Bitcoin Core developers +# 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. diff --git a/src/qml/test/org/bitcoincore/qt/AppMode.qml b/src/qml/test/org/bitcoincore/qt/AppMode.qml index 00d0d57a95..6a96a929b3 100644 --- a/src/qml/test/org/bitcoincore/qt/AppMode.qml +++ b/src/qml/test/org/bitcoincore/qt/AppMode.qml @@ -1,3 +1,7 @@ +// 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. + pragma Singleton import QtQuick 2.15 diff --git a/src/qml/test/org/bitcoincore/qt/qmldir b/src/qml/test/org/bitcoincore/qt/qmldir index 56f01a045b..a608a4b706 100644 --- a/src/qml/test/org/bitcoincore/qt/qmldir +++ b/src/qml/test/org/bitcoincore/qt/qmldir @@ -1,2 +1,6 @@ +# 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. + module org.bitcoincore.qt singleton AppMode 1.0 AppMode.qml diff --git a/src/qml/test/setup.h b/src/qml/test/setup.h index 074a27f047..77b9757f12 100644 --- a/src/qml/test/setup.h +++ b/src/qml/test/setup.h @@ -1,4 +1,4 @@ -// Copyright (c) 2014-2023 The Bitcoin Core developers +// 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. #ifndef BITCOIN_QML_TEST_SETUP_H diff --git a/src/qml/test/tst_onboarding.qml b/src/qml/test/tst_onboarding.qml index 3bafb9958a..e2a9e66ad0 100644 --- a/src/qml/test/tst_onboarding.qml +++ b/src/qml/test/tst_onboarding.qml @@ -1,3 +1,7 @@ +// 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. + import QtQuick 2.15 import QtTest 1.15 import "../controls" From e30956878f6936585639fc2d2f50bd8d0d66b255 Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Sat, 14 Jan 2023 15:03:59 -0500 Subject: [PATCH 18/20] qmltest: remove extra flags/link aguments from makefile --- src/Makefile.qmltest.include | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Makefile.qmltest.include b/src/Makefile.qmltest.include index 83c435840b..ec99ad907c 100644 --- a/src/Makefile.qmltest.include +++ b/src/Makefile.qmltest.include @@ -9,8 +9,8 @@ TEST_QML_MOC_CPP = qml/test/moc_setup.cpp TEST_QML_H = qml/test/setup.h qml/test/testimageprovider.h -qml_test_test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) $(BITCOIN_QT_INCLUDES) \ - $(QT_INCLUDES) $(QT_TEST_INCLUDES) $(QT_QUICKTEST_INCLUDES) $(BOOST_CPPFLAGS) $(QT_QUICKTEST_CFLAGS) +qml_test_test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) \ + $(QT_INCLUDES) $(QT_QUICKTEST_INCLUDES) $(BOOST_CPPFLAGS) $(QT_QUICKTEST_CFLAGS) qml_test_test_bitcoin_qt_SOURCES = \ qml/test/setup.cpp \ @@ -20,7 +20,7 @@ qml_test_test_bitcoin_qt_SOURCES = \ nodist_qml_test_test_bitcoin_qt_SOURCES = $(TEST_QML_MOC_CPP) $(QML_QRC_CPP) -qml_test_test_bitcoin_qt_LDADD = $(QT_QUICKTEST_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) +qml_test_test_bitcoin_qt_LDADD = $(QT_QUICKTEST_LIBS) $(QT_LIBS) qml_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) qml_test_test_bitcoin_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) From 9176f79b78613cc697e602b1a63c946dc01bd093 Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Mon, 16 Jan 2023 00:16:37 -0500 Subject: [PATCH 19/20] qmltest: fix build and don't build when static linking Co-authored-by: Hennadii Stepanov <32963518+hebasto@users.noreply.github.com> --- build-aux/m4/bitcoin_qt.m4 | 9 +++++---- ci/test/00_setup_env_mac_native.sh | 2 +- configure.ac | 3 ++- src/Makefile.qmltest.include | 10 +++++----- src/qml/test/setup.cpp | 7 +++++++ 5 files changed, 20 insertions(+), 11 deletions(-) diff --git a/build-aux/m4/bitcoin_qt.m4 b/build-aux/m4/bitcoin_qt.m4 index 52174edb8c..a7602e3f09 100644 --- a/build-aux/m4/bitcoin_qt.m4 +++ b/build-aux/m4/bitcoin_qt.m4 @@ -108,7 +108,7 @@ dnl BITCOIN_QT_CONFIGURE([MINIMUM-VERSION]) dnl dnl Outputs: See _BITCOIN_QT_FIND_LIBS dnl Outputs: Sets variables for all qt-related tools. -dnl Outputs: bitcoin_enable_qt, bitcoin_enable_qt_dbus, bitcoin_enable_qt_test +dnl Outputs: bitcoin_enable_qt, bitcoin_enable_qt_dbus, bitcoin_enable_qt_test, bitcoin_enable_qml_test AC_DEFUN([BITCOIN_QT_CONFIGURE],[ qt_version=">= $1" qt_lib_prefix="Qt5" @@ -321,7 +321,7 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[ bitcoin_enable_qt_test=no fi bitcoin_enable_qml_test=yes - if test "$have_qml_test" = "no"; then + if test "$have_quick_test" = "no" || test "$bitcoin_cv_static_qt" = "yes"; then bitcoin_enable_qml_test=no fi bitcoin_enable_qt_dbus=no @@ -352,6 +352,7 @@ AC_DEFUN([BITCOIN_QT_CONFIGURE],[ AC_SUBST(QT_LDFLAGS) AC_SUBST(QT_DBUS_INCLUDES) AC_SUBST(QT_TEST_INCLUDES) + AC_SUBST(QT_QMLTEST_INCLUDES) AC_SUBST(QT_SELECT, qt5) AC_SUBST(MOC_DEFS) ]) @@ -442,7 +443,7 @@ dnl _BITCOIN_QT_FIND_LIBS dnl --------------------- dnl dnl Outputs: All necessary QT_* variables are set. -dnl Outputs: have_qt_test and have_qt_dbus are set (if applicable) to yes|no. +dnl Outputs: have_qt_test, have_quick_test, and have_qt_dbus are set (if applicable) to yes|no. AC_DEFUN([_BITCOIN_QT_FIND_LIBS],[ BITCOIN_QT_CHECK([ PKG_CHECK_MODULES([QT_CORE], [${qt_lib_prefix}Core${qt_lib_suffix} $qt_version], [QT_INCLUDES="$QT_CORE_CFLAGS $QT_INCLUDES" QT_LIBS="$QT_CORE_LIBS $QT_LIBS"], @@ -486,7 +487,7 @@ AC_DEFUN([_BITCOIN_QT_FIND_LIBS],[ [BITCOIN_QT_FAIL([${qt_lib_prefix}QuickControls2${qt_lib_suffix} $qt_version not found])]) ]) BITCOIN_QT_CHECK([ - PKG_CHECK_MODULES([QT_QUICKTEST], [${qt_lib_prefix}QuickTest${qt_lib_suffix} $qt_version], [QT_QMLTEST_INCLUDES="$QT_QUICKTEST_CFLAGS"; have_quick_test=yes],[have_quick_test=no]) + PKG_CHECK_MODULES([QT_QUICKTEST], [${qt_lib_prefix}QuickTest${qt_lib_suffix} $qt_version], [QT_QMLTEST_INCLUDES="$QT_QUICKTEST_CFLAGS"; have_quick_test=yes], [have_quick_test=no]) ]) AC_DEFINE([USE_QML], [1], [Define to 1 to use QML-based GUI]) diff --git a/ci/test/00_setup_env_mac_native.sh b/ci/test/00_setup_env_mac_native.sh index c9f65bf397..709229c524 100755 --- a/ci/test/00_setup_env_mac_native.sh +++ b/ci/test/00_setup_env_mac_native.sh @@ -9,7 +9,7 @@ export LC_ALL=C.UTF-8 export HOST=x86_64-apple-darwin export PIP_PACKAGES="zmq" export GOAL="install" -export BITCOIN_CONFIG="--with-gui --with-miniupnpc --with-natpmp --enable-reduce-exports" +export BITCOIN_CONFIG="--with-gui --with-miniupnpc --with-natpmp --enable-reduce-exports CXXFLAGS=-Wno-shadow-field" export CI_OS_NAME="macos" export NO_DEPENDS=1 export OSX_SDK="" diff --git a/configure.ac b/configure.ac index eec43d30a7..31ec4eae5d 100644 --- a/configure.ac +++ b/configure.ac @@ -1314,6 +1314,7 @@ if test "$enable_fuzz" = "yes"; then build_bitcoin_libs=no bitcoin_enable_qt=no bitcoin_enable_qt_test=no + bitcoin_enable_qml_test=no bitcoin_enable_qt_dbus=no use_bench=no use_tests=no @@ -1327,7 +1328,7 @@ if test "$enable_fuzz" = "yes"; then else BITCOIN_QT_INIT - dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qt_dbus + dnl sets $bitcoin_enable_qt, $bitcoin_enable_qt_test, $bitcoin_enable_qml_test, $bitcoin_enable_qt_dbus BITCOIN_QT_CONFIGURE([5.11.3]) dnl Keep a copy of the original $QT_INCLUDES and use it when invoking qt's moc diff --git a/src/Makefile.qmltest.include b/src/Makefile.qmltest.include index ec99ad907c..b1293bba09 100644 --- a/src/Makefile.qmltest.include +++ b/src/Makefile.qmltest.include @@ -10,17 +10,17 @@ TEST_QML_MOC_CPP = qml/test/moc_setup.cpp TEST_QML_H = qml/test/setup.h qml/test/testimageprovider.h qml_test_test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) \ - $(QT_INCLUDES) $(QT_QUICKTEST_INCLUDES) $(BOOST_CPPFLAGS) $(QT_QUICKTEST_CFLAGS) + $(QT_INCLUDES) $(QT_QMLTEST_INCLUDES) $(BOOST_CPPFLAGS) qml_test_test_bitcoin_qt_SOURCES = \ - qml/test/setup.cpp \ qml/bitcoin_qml.qrc \ + qml/test/setup.cpp \ qml/test/testimageprovider.cpp \ $(TEST_QML_H) nodist_qml_test_test_bitcoin_qt_SOURCES = $(TEST_QML_MOC_CPP) $(QML_QRC_CPP) -qml_test_test_bitcoin_qt_LDADD = $(QT_QUICKTEST_LIBS) $(QT_LIBS) +qml_test_test_bitcoin_qt_LDADD = $(QT_LIBS) $(QT_QUICKTEST_LIBS) qml_test_test_bitcoin_qt_LDFLAGS = $(RELDFLAGS) $(AM_LDFLAGS) $(QT_LDFLAGS) $(LIBTOOL_APP_LDFLAGS) $(PTHREAD_FLAGS) qml_test_test_bitcoin_qt_CXXFLAGS = $(AM_CXXFLAGS) $(QT_PIE_FLAGS) @@ -28,9 +28,9 @@ CLEAN_BITCOIN_QML_TEST = $(TEST_QML_MOC_CPP) CLEANFILES += $(CLEAN_BITCOIN_QML_TEST) -test_bitcoin_qt_qml : qml/test/test_bitcoin-qt-qml$(EXEEXT) +test_bitcoin_qt_qml: qml/test/test_bitcoin-qt$(EXEEXT) -test_bitcoin_qt_qml_check : qt/test/test_bitcoin-qt-qml$(EXEEXT) FORCE +test_bitcoin_qt_qml_check: qml/test/test_bitcoin-qt$(EXEEXT) FORCE $(MAKE) check-TESTS TESTS=$^ test_bitcoin_qt_qml_clean: FORCE diff --git a/src/qml/test/setup.cpp b/src/qml/test/setup.cpp index 3de12a5ebc..3144a82e88 100644 --- a/src/qml/test/setup.cpp +++ b/src/qml/test/setup.cpp @@ -1,9 +1,16 @@ // 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 +#if defined(HAVE_CONFIG_H) +#include +#endif + #include +#include +#include #include #include #include From ed8222b7dfb87d6150ad17cd71bfed76d0745202 Mon Sep 17 00:00:00 2001 From: Johnny Carlson Date: Mon, 16 Jan 2023 17:39:35 -0500 Subject: [PATCH 20/20] qmltest: remove from TESTS until able to run in ci --- src/Makefile.qmltest.include | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Makefile.qmltest.include b/src/Makefile.qmltest.include index b1293bba09..2fc56e6d24 100644 --- a/src/Makefile.qmltest.include +++ b/src/Makefile.qmltest.include @@ -3,7 +3,6 @@ # file COPYING or http://www.opensource.org/licenses/mit-license.php. bin_PROGRAMS += qml/test/test_bitcoin-qt -TESTS += qml/test/test_bitcoin-qt TEST_QML_MOC_CPP = qml/test/moc_setup.cpp @@ -30,8 +29,5 @@ CLEANFILES += $(CLEAN_BITCOIN_QML_TEST) test_bitcoin_qt_qml: qml/test/test_bitcoin-qt$(EXEEXT) -test_bitcoin_qt_qml_check: qml/test/test_bitcoin-qt$(EXEEXT) FORCE - $(MAKE) check-TESTS TESTS=$^ - test_bitcoin_qt_qml_clean: FORCE rm -f $(CLEAN_BITCOIN_QML_TEST) $(qml_test_test_bitcoin_qt_OBJECTS)