diff options
author | MarcoFalke <falke.marco@gmail.com> | 2019-01-09 14:38:28 +0100 |
---|---|---|
committer | MarcoFalke <falke.marco@gmail.com> | 2019-01-09 14:40:38 +0100 |
commit | fdbe7f41c02847276e980724e49865daf7951214 (patch) | |
tree | 2269493cdc34a8b0a3cd8dcc071a98def95e8c36 /src/qt/test/apptests.h | |
parent | c6806ee8694e9c864a29ef260c87b9fed77de84f (diff) | |
parent | 7e4bd19785ff9120b7242ff9f15231868aaf7db4 (diff) | |
download | bitcoin-fdbe7f41c02847276e980724e49865daf7951214.tar.xz |
Merge #11625: Add BitcoinApplication & RPCConsole tests
7e4bd19785 Add BitcoinApplication & RPCConsole tests (Russell Yanofsky)
ca20b65cc0 Move BitcoinApplication to header so it can be tested (Russell Yanofsky)
Pull request description:
Add test coverage for Qt initialization code & basic RPC console functionality
Motivation for this change was a bug in #11603 which existing tests failed to catch.
Tree-SHA512: f66546ffc84b8e07679c66a73b265023fbf6a0cb8f24f1606a5fcae2dd3b4dc7b2c6d26c69dedcec53398a26ef17c4d5fb28c055698fa6e45e89aa2995cefe2f
Diffstat (limited to 'src/qt/test/apptests.h')
-rw-r--r-- | src/qt/test/apptests.h | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/src/qt/test/apptests.h b/src/qt/test/apptests.h new file mode 100644 index 0000000000..83bf56f1e4 --- /dev/null +++ b/src/qt/test/apptests.h @@ -0,0 +1,50 @@ +// Copyright (c) 2018 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_QT_TEST_APPTESTS_H +#define BITCOIN_QT_TEST_APPTESTS_H + +#include <QObject> +#include <set> +#include <string> +#include <utility> + +class BitcoinApplication; +class BitcoinGUI; +class RPCConsole; + +class AppTests : public QObject +{ + Q_OBJECT +public: + explicit AppTests(BitcoinApplication& app) : m_app(app) {} + +private Q_SLOTS: + void appTests(); + void guiTests(BitcoinGUI* window); + void consoleTests(RPCConsole* console); + +private: + //! Add expected callback name to list of pending callbacks. + void expectCallback(std::string callback) { m_callbacks.emplace(std::move(callback)); } + + //! RAII helper to remove no-longer-pending callback. + struct HandleCallback + { + std::string m_callback; + AppTests& m_app_tests; + ~HandleCallback(); + }; + + //! Bitcoin application. + BitcoinApplication& m_app; + + //! Set of pending callback names. Used to track expected callbacks and shut + //! down the app after the last callback has been handled and all tests have + //! either run or thrown exceptions. This could be a simple int counter + //! instead of a set of names, but the names might be useful for debugging. + std::multiset<std::string> m_callbacks; +}; + +#endif // BITCOIN_QT_TEST_APPTESTS_H |