Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create QML test automation target (qml/test/test_bitcoin-qt) #215

Open
wants to merge 20 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
13 changes: 11 additions & 2 deletions build-aux/m4/bitcoin_qt.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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_quick_test" = "no" || test "$bitcoin_cv_static_qt" = "yes"; 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
Expand Down Expand Up @@ -348,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)
])
Expand Down Expand Up @@ -438,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"],
Expand Down Expand Up @@ -481,6 +486,10 @@ 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_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])
fi
])
2 changes: 1 addition & 1 deletion ci/test/00_setup_env_mac_native.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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=""
Expand Down
15 changes: 13 additions & 2 deletions configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -1764,8 +1765,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
Expand Down Expand Up @@ -1801,6 +1803,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_qml$use_gui_tests$bitcoin_enable_qml_test" = "yesyesyes"; then
AC_MSG_RESULT([yes])
BUILD_TEST_QML="yes"
else
AC_MSG_RESULT([no])
fi
fi

AC_MSG_CHECKING([whether to build test_bitcoin])
Expand Down Expand Up @@ -1840,6 +1850,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"])
Expand Down
4 changes: 4 additions & 0 deletions src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -1147,4 +1147,8 @@ if ENABLE_QT_TESTS
include Makefile.qttest.include
endif

if ENABLE_QML_TESTS
include Makefile.qmltest.include
endif

include Makefile.univalue.include
33 changes: 33 additions & 0 deletions src/Makefile.qmltest.include
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# 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.

bin_PROGRAMS += qml/test/test_bitcoin-qt

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_QMLTEST_INCLUDES) $(BOOST_CPPFLAGS)

qml_test_test_bitcoin_qt_SOURCES = \
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_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)

CLEAN_BITCOIN_QML_TEST = $(TEST_QML_MOC_CPP)

CLEANFILES += $(CLEAN_BITCOIN_QML_TEST)

test_bitcoin_qt_qml: qml/test/test_bitcoin-qt$(EXEEXT)

test_bitcoin_qt_qml_clean: FORCE
rm -f $(CLEAN_BITCOIN_QML_TEST) $(qml_test_test_bitcoin_qt_OBJECTS)
1 change: 1 addition & 0 deletions src/Makefile.qt.include
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
1 change: 1 addition & 0 deletions src/qml/bitcoin_qml.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
<file>pages/onboarding/OnboardingStorageAmount.qml</file>
<file>pages/onboarding/OnboardingStorageLocation.qml</file>
<file>pages/onboarding/OnboardingStrengthen.qml</file>
<file>pages/onboarding/OnboardingWizard.qml</file>
johnny9 marked this conversation as resolved.
Show resolved Hide resolved
<file>pages/settings/SettingsAbout.qml</file>
<file>pages/settings/SettingsBlockClockDisplayMode.qml</file>
<file>pages/settings/SettingsConnection.qml</file>
Expand Down
1 change: 1 addition & 0 deletions src/qml/controls/ContinueButton.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 1 addition & 12 deletions src/qml/pages/main.qml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
1 change: 1 addition & 0 deletions src/qml/pages/onboarding/OnboardingBlockclock.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import QtQuick.Layouts 1.15
import "../../controls"

InformationPage {
objectName: "onboardingBlockClock"
navLeftDetail: NavButton {
iconSource: "image://images/caret-left"
text: qsTr("Back")
Expand Down
1 change: 1 addition & 0 deletions src/qml/pages/onboarding/OnboardingConnection.qml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import "../settings"

Page {
background: null
objectName: "onboardingConnection"
clip: true
SwipeView {
id: connections
Expand Down
1 change: 1 addition & 0 deletions src/qml/pages/onboarding/OnboardingCover.qml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import "../settings"
Page {
background: null
clip: true
objectName: "onboardingCover"
SwipeView {
id: introductions
anchors.fill: parent
Expand Down
1 change: 1 addition & 0 deletions src/qml/pages/onboarding/OnboardingStorageAmount.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "../../components"
import "../settings"

Page {
objectName: "onboardingStorageAmount"
background: null
clip: true
SwipeView {
Expand Down
1 change: 1 addition & 0 deletions src/qml/pages/onboarding/OnboardingStorageLocation.qml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import "../../controls"
import "../../components"

InformationPage {
objectName: "onboardingStorageLocation"
navLeftDetail: NavButton {
iconSource: "image://images/caret-left"
text: qsTr("Back")
Expand Down
1 change: 1 addition & 0 deletions src/qml/pages/onboarding/OnboardingStrengthen.qml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import QtQuick.Layouts 1.15
import "../../controls"

InformationPage {
objectName: "onboardingStrengthen"
navLeftDetail: NavButton {
iconSource: "image://images/caret-left"
text: qsTr("Back")
Expand Down
19 changes: 19 additions & 0 deletions src/qml/pages/onboarding/OnboardingWizard.qml
Original file line number Diff line number Diff line change
@@ -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 {}
}
16 changes: 16 additions & 0 deletions src/qml/test/org/bitcoincore/qt/AppMode.qml
Original file line number Diff line number Diff line change
@@ -0,0 +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.

pragma Singleton
johnny9 marked this conversation as resolved.
Show resolved Hide resolved
import QtQuick 2.15

Item {
property bool isDesktop: true
property bool isMobile: false
enum Mode {
DESKTOP,
MOBILE
}
property string state: "MOBILE"
}
6 changes: 6 additions & 0 deletions src/qml/test/org/bitcoincore/qt/qmldir
Original file line number Diff line number Diff line change
@@ -0,0 +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
22 changes: 22 additions & 0 deletions src/qml/test/setup.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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/setup.h>

#if defined(HAVE_CONFIG_H)
#include <config/bitcoin-config.h>
#endif

#include <QtQuickTest>
#include <QtTest>
#include <QtTest/qtestcase.h>
#include <QQmlEngine>
#include <QQmlContext>
#include <qml/test/testimageprovider.h>

void Setup::qmlEngineAvailable(QQmlEngine * engine) {
engine->addImageProvider(QStringLiteral("images"), new TestImageProvider());
}

QUICK_TEST_MAIN_WITH_SETUP(onboarding, Setup)
22 changes: 22 additions & 0 deletions src/qml/test/setup.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
// 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
#define BITCOIN_QML_TEST_SETUP_H

#include <QObject>
#include <QQmlEngine>

class Setup : public QObject
{
Q_OBJECT

public:
Setup() = default;
~Setup() = default;

public Q_SLOTS:
void qmlEngineAvailable(QQmlEngine * engine);
};

#endif // BITCOIN_QML_TEST_SETUP_H
Loading