forked from dashpay/dash
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[tests] [qt] Introduce qt/test/util with a generalized ConfirmMessage
ConfirmMessage is reused in future tests apart from its single usage here.
- Loading branch information
Showing
4 changed files
with
38 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#include <qt/callback.h> | ||
|
||
#include <QApplication> | ||
#include <QMessageBox> | ||
#include <QTimer> | ||
#include <QString> | ||
#include <QPushButton> | ||
#include <QWidget> | ||
|
||
void ConfirmMessage(QString* text, int msec) | ||
{ | ||
QTimer::singleShot(msec, makeCallback([text](Callback* callback) { | ||
for (QWidget* widget : QApplication::topLevelWidgets()) { | ||
if (widget->inherits("QMessageBox")) { | ||
QMessageBox* messageBox = qobject_cast<QMessageBox*>(widget); | ||
if (text) *text = messageBox->text(); | ||
messageBox->defaultButton()->click(); | ||
} | ||
} | ||
delete callback; | ||
}), SLOT(call())); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef BITCOIN_QT_TEST_UTIL_H | ||
#define BITCOIN_QT_TEST_UTIL_H | ||
|
||
/** | ||
* Press "Ok" button in message box dialog. | ||
* | ||
* @param text - Optionally store dialog text. | ||
* @param msec - Number of miliseconds to pause before triggering the callback. | ||
*/ | ||
void ConfirmMessage(QString* text = nullptr, int msec = 0); | ||
|
||
#endif // BITCOIN_QT_TEST_UTIL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters