diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-04-25 19:15:30 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2018-04-25 19:32:32 +0200 |
commit | 25ad2f75f5d105d30d2ca716a66138a6b32a8c68 (patch) | |
tree | 0836355a6740398437a4ffab523ffa78886fdde0 /src/qt/test/util.cpp | |
parent | a785bc3667d3c11a014da77436a23b1b865458a4 (diff) | |
parent | 5109fc4a9cb2cbd73c33197fb9129e1413ab051b (diff) |
Merge #12830: [qt] [tests] Clarify address book error messages, add tests
5109fc4 [tests] [qt] Add tests for address book manipulation via EditAddressDialog (James O'Beirne)
9c01be1 [tests] [qt] Introduce qt/test/util with a generalized ConfirmMessage (James O'Beirne)
8cdcaee [qt] Display more helpful message when adding a send address has failed (James O'Beirne)
c5b2770 Add purpose arg to Wallet::getAddress (James O'Beirne)
Pull request description:
Addresses https://github.com/bitcoin/bitcoin/issues/12796.
When a user attempts to add to the address book a sending address which is already present as a receiving address, they're presented with a confusing error indicating the address is already present in the book, despite the fact that this row is currently invisible.

This change adds a more specific error message indicating its existence as a receiving address (as discussed in the linked issue).

This change also adds some tests exercising use of the address book via QT. Adding so much test code for such a trivial change may seem weird, but it's my hope that this will make further test-writing for address book usage (and other QT features) more approachable.
Tree-SHA512: fbdd5564f7a9a2380bbe437f3378e8d4d5fd9201efff4879b72bc23f2cc1c2eecaf2b811994c25070ee052422e48e47901787c2e62cc584774a997fe6a2a327a
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())); +} |