ConfirmMessage is reused in future tests apart from its single usage here.pull/585/head
parent
8cdcaee4c7
commit
9c01be1b85
@ -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()));
|
||||
}
|
@ -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
|
Loading…
Reference in new issue