aboutsummaryrefslogtreecommitdiff
path: root/src/qt/test/apptests.h
diff options
context:
space:
mode:
authorRussell Yanofsky <russ@yanofsky.org>2017-11-06 20:11:43 -0500
committerRussell Yanofsky <russ@yanofsky.org>2019-01-04 06:31:07 -0500
commit7e4bd19785ff9120b7242ff9f15231868aaf7db4 (patch)
tree6a08b07a7be3233661b9a1bf973d77fa81a31109 /src/qt/test/apptests.h
parentca20b65cc04825bb317f1a59d02c77912f6bf097 (diff)
downloadbitcoin-7e4bd19785ff9120b7242ff9f15231868aaf7db4.tar.xz
Add BitcoinApplication & RPCConsole tests
Add test coverage for Qt initialization code & basic RPC console functionality.
Diffstat (limited to 'src/qt/test/apptests.h')
-rw-r--r--src/qt/test/apptests.h50
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