diff options
author | James O'Beirne <james.obeirne@gmail.com> | 2018-03-29 10:56:04 -0400 |
---|---|---|
committer | James O'Beirne <james.obeirne@gmail.com> | 2018-04-25 13:08:53 -0400 |
commit | 9c01be1b85f8ad11a8a0826a4a2bcdc2668a5c1f (patch) | |
tree | c689ea08afebf413262c2cf33e07b000156024dd /src/qt/test/util.cpp | |
parent | 8cdcaee4c7b256c5c3b70f1cfb04a5fb547311cd (diff) | |
download | bitcoin-9c01be1b85f8ad11a8a0826a4a2bcdc2668a5c1f.tar.xz |
[tests] [qt] Introduce qt/test/util with a generalized ConfirmMessage
ConfirmMessage is reused in future tests apart from its single usage here.
Diffstat (limited to 'src/qt/test/util.cpp')
-rw-r--r-- | src/qt/test/util.cpp | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/src/qt/test/util.cpp b/src/qt/test/util.cpp new file mode 100644 index 0000000000..261caaaee5 --- /dev/null +++ b/src/qt/test/util.cpp @@ -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())); +} |