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 = \
20
20
qt/test/compattests.h \
21
21
qt/test/rpcnestedtests.h \
22
22
qt/test/uritests.h \
23
+ qt/test/util.h \
23
24
qt/test/paymentrequestdata.h \
24
25
qt/test/paymentservertests.h \
25
26
qt/test/wallettests.h
@@ -38,6 +39,7 @@ qt_test_test_bitcoin_qt_SOURCES = \
38
39
qt/test/rpcnestedtests.cpp \
39
40
qt/test/test_main.cpp \
40
41
qt/test/uritests.cpp \
42
+ qt/test/util.cpp \
41
43
$(TEST_QT_H) \
42
44
$(TEST_BITCOIN_CPP) \
43
45
$(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 1
1
#include < qt/test/wallettests.h>
2
+ #include < qt/test/util.h>
2
3
3
4
#include < interfaces/node.h>
4
5
#include < qt/bitcoinamountfield.h>
35
36
36
37
namespace
37
38
{
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
-
53
39
// ! Press "Yes" or "Cancel" buttons in modal send confirmation dialog.
54
40
void ConfirmSend (QString* text = nullptr , bool cancel = false )
55
41
{
@@ -264,7 +250,7 @@ void TestGUI()
264
250
QCOMPARE (requestTableModel->rowCount ({}), currentRowCount-1 );
265
251
}
266
252
267
- }
253
+ } // namespace
268
254
269
255
void WalletTests::walletTests ()
270
256
{
You can’t perform that action at this time.
0 commit comments