mirror of
https://github.com/dashpay/dash.git
synced 2024-12-24 19:42:46 +01:00
merge bitcoin-core/gui#337: Use Regex Search in Apptests
This commit is contained in:
parent
3a18f087bf
commit
17a7e9ba85
@ -12,7 +12,6 @@
|
||||
#include <qt/rpcconsole.h>
|
||||
#include <shutdown.h>
|
||||
#include <test/util/setup_common.h>
|
||||
#include <univalue.h>
|
||||
#include <validation.h>
|
||||
|
||||
#if defined(HAVE_CONFIG_H)
|
||||
@ -21,9 +20,11 @@
|
||||
|
||||
#include <QAction>
|
||||
#include <QLineEdit>
|
||||
#include <QRegularExpression>
|
||||
#include <QScopedPointer>
|
||||
#include <QSettings>
|
||||
#include <QSignalSpy>
|
||||
#include <QString>
|
||||
#include <QTest>
|
||||
#include <QTextEdit>
|
||||
#include <QtGlobal>
|
||||
@ -31,6 +32,13 @@
|
||||
#include <QtTest/QtTestGui>
|
||||
|
||||
namespace {
|
||||
//! Regex find a string group inside of the console output
|
||||
QString FindInConsole(const QString& output, const QString& pattern)
|
||||
{
|
||||
const QRegularExpression re(pattern);
|
||||
return re.match(output).captured(1);
|
||||
}
|
||||
|
||||
//! Call getblockchaininfo RPC and check first field of JSON output.
|
||||
void TestRpcCommand(RPCConsole* console)
|
||||
{
|
||||
@ -42,10 +50,9 @@ void TestRpcCommand(RPCConsole* console)
|
||||
QTest::keyClick(lineEdit, Qt::Key_Return);
|
||||
QVERIFY(mw_spy.wait(1000));
|
||||
QCOMPARE(mw_spy.count(), 4);
|
||||
QString output = messagesWidget->toPlainText();
|
||||
UniValue value;
|
||||
value.read(output.right(output.size() - output.indexOf("{")).toStdString());
|
||||
QCOMPARE(value["chain"].get_str(), std::string("regtest"));
|
||||
const QString output = messagesWidget->toPlainText();
|
||||
const QString pattern = QStringLiteral("\"chain\": \"(\\w+)\"");
|
||||
QCOMPARE(FindInConsole(output, pattern), QString("regtest"));
|
||||
}
|
||||
} // namespace
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user