refactor, qt: Use std::chrono in ConfirmMessage parameter

This commit is contained in:
Hennadii Stepanov 2022-01-06 18:30:58 +02:00
parent 33d520ac53
commit 6f0da95811
No known key found for this signature in database
GPG Key ID: 410108112E7EA81F
4 changed files with 14 additions and 5 deletions

View File

@ -20,6 +20,8 @@
#include <wallet/wallet.h>
#include <walletinitinterface.h>
#include <chrono>
#include <QApplication>
#include <QTimer>
#include <QMessageBox>
@ -40,7 +42,7 @@ void EditAddressAndSubmit(
dialog->findChild<QLineEdit*>("labelEdit")->setText(label);
dialog->findChild<QValidatedLineEdit*>("addressEdit")->setText(address);
ConfirmMessage(&warning_text, 5);
ConfirmMessage(&warning_text, 5ms);
dialog->accept();
QCOMPARE(warning_text, expected_msg);
}

View File

@ -2,6 +2,8 @@
// Distributed under the MIT software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include <chrono>
#include <QApplication>
#include <QMessageBox>
#include <QPushButton>
@ -9,7 +11,7 @@
#include <QTimer>
#include <QWidget>
void ConfirmMessage(QString* text, int msec)
void ConfirmMessage(QString* text, std::chrono::milliseconds msec)
{
QTimer::singleShot(msec, [text]() {
for (QWidget* widget : QApplication::topLevelWidgets()) {

View File

@ -5,7 +5,11 @@
#ifndef BITCOIN_QT_TEST_UTIL_H
#define BITCOIN_QT_TEST_UTIL_H
#include <QString>
#include <chrono>
QT_BEGIN_NAMESPACE
class QString;
QT_END_NAMESPACE
/**
* Press "Ok" button in message box dialog.
@ -13,6 +17,6 @@
* @param text - Optionally store dialog text.
* @param msec - Number of milliseconds to pause before triggering the callback.
*/
void ConfirmMessage(QString* text = nullptr, int msec = 0);
void ConfirmMessage(QString* text, std::chrono::milliseconds msec);
#endif // BITCOIN_QT_TEST_UTIL_H

View File

@ -26,6 +26,7 @@
#include <qt/recentrequeststablemodel.h>
#include <qt/receiverequestdialog.h>
#include <chrono>
#include <memory>
#include <QAbstractButton>
@ -112,7 +113,7 @@ void BumpFee(TransactionView& view, const uint256& txid, bool expectDisabled, st
if (expectError.empty()) {
ConfirmSend(&text, cancel);
} else {
ConfirmMessage(&text);
ConfirmMessage(&text, 0ms);
}
action->trigger();
QVERIFY(text.indexOf(QString::fromStdString(expectError)) != -1);