File tree Expand file tree Collapse file tree 4 files changed +38
-16
lines changed
Expand file tree Collapse file tree 4 files changed +38
-16
lines changed Original file line number Diff line number Diff line change @@ -20,6 +20,7 @@ TEST_QT_H = \
2020 qt/test/compattests.h \
2121 qt/test/rpcnestedtests.h \
2222 qt/test/uritests.h \
23+ qt/test/util.h \
2324 qt/test/paymentrequestdata.h \
2425 qt/test/paymentservertests.h \
2526 qt/test/wallettests.h
@@ -38,6 +39,7 @@ qt_test_test_bitcoin_qt_SOURCES = \
3839 qt/test/rpcnestedtests.cpp \
3940 qt/test/test_main.cpp \
4041 qt/test/uritests.cpp \
42+ qt/test/util.cpp \
4143 $(TEST_QT_H) \
4244 $(TEST_BITCOIN_CPP) \
4345 $(TEST_BITCOIN_H)
Original file line number Diff line number Diff line change 1+ #include < qt/callback.h>
2+
3+ #include < QApplication>
4+ #include < QMessageBox>
5+ #include < QTimer>
6+ #include < QString>
7+ #include < QPushButton>
8+ #include < QWidget>
9+
10+ void ConfirmMessage (QString* text, int msec)
11+ {
12+ QTimer::singleShot (msec, makeCallback ([text](Callback* callback) {
13+ for (QWidget* widget : QApplication::topLevelWidgets ()) {
14+ if (widget->inherits (" QMessageBox" )) {
15+ QMessageBox* messageBox = qobject_cast<QMessageBox*>(widget);
16+ if (text) *text = messageBox->text ();
17+ messageBox->defaultButton ()->click ();
18+ }
19+ }
20+ delete callback;
21+ }), SLOT (call ()));
22+ }
Original file line number Diff line number Diff line change 1+ #ifndef BITCOIN_QT_TEST_UTIL_H
2+ #define BITCOIN_QT_TEST_UTIL_H
3+
4+ /**
5+ * Press "Ok" button in message box dialog.
6+ *
7+ * @param text - Optionally store dialog text.
8+ * @param msec - Number of miliseconds to pause before triggering the callback.
9+ */
10+ void ConfirmMessage (QString * text = nullptr , int msec = 0 );
11+
12+ #endif // BITCOIN_QT_TEST_UTIL_H
Original file line number Diff line number Diff line change 11#include < qt/test/wallettests.h>
2+ #include < qt/test/util.h>
23
34#include < interfaces/node.h>
45#include < qt/bitcoinamountfield.h>
3536
3637namespace
3738{
38- // ! Press "Ok" button in message box dialog.
39- void ConfirmMessage (QString* text = nullptr )
40- {
41- QTimer::singleShot (0 , makeCallback ([text](Callback* callback) {
42- for (QWidget* widget : QApplication::topLevelWidgets ()) {
43- if (widget->inherits (" QMessageBox" )) {
44- QMessageBox* messageBox = qobject_cast<QMessageBox*>(widget);
45- if (text) *text = messageBox->text ();
46- messageBox->defaultButton ()->click ();
47- }
48- }
49- delete callback;
50- }), SLOT (call ()));
51- }
52-
5339// ! Press "Yes" or "Cancel" buttons in modal send confirmation dialog.
5440void ConfirmSend (QString* text = nullptr , bool cancel = false )
5541{
@@ -264,7 +250,7 @@ void TestGUI()
264250 QCOMPARE (requestTableModel->rowCount ({}), currentRowCount-1 );
265251}
266252
267- }
253+ } // namespace
268254
269255void WalletTests::walletTests ()
270256{
You can’t perform that action at this time.
0 commit comments