aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-05-09 22:05:02 +0200
committerHennadii Stepanov <32963518+hebasto@users.noreply.github.com>2022-05-09 22:19:39 +0200
commit3dd95cb5c2917f7216d0a06d163bc940ee9ad85a (patch)
tree7a4cb2ca9d9f13b5d27338de87b97408cec9a81d
parenta8098f2cef53ec003edae91100afce564e9c6f23 (diff)
parent15069130c6ca5273f3a593a404f60f11caa7d950 (diff)
Merge bitcoin-core/gui#591: test: Add tests for `tableView` in `AddressBookPage` dialog
15069130c6ca5273f3a593a404f60f11caa7d950 qt, test: Add tests for `tableView` in `AddressBookPage` dialog (Hennadii Stepanov) edae3ab6999ee9e6efabd8403d31e9bd7c84f8a3 qt: No need to force Qt::QueuedConnection for NotifyAddressBookChanged (Hennadii Stepanov) Pull request description: This PR is a prerequisite for more thorough testing of filtering in the `AddressBookPage` class in context of bitcoin-core/gui#578 and bitcoin-core/gui#585. Required for bitcoin-core/gui#592. ACKs for top commit: promag: Code review ACK 15069130c6ca5273f3a593a404f60f11caa7d950. Tree-SHA512: 86986d47606cbd54d813436c7afb21894e2200b6d3042a7aa0b5e84821c765bd68b14ad38a445069891ab33f2d7bcd4933b8373e14e9afb0c91f1a6ddf4da740
-rw-r--r--src/qt/test/addressbooktests.cpp15
-rw-r--r--src/qt/walletmodel.cpp2
2 files changed, 12 insertions, 5 deletions
diff --git a/src/qt/test/addressbooktests.cpp b/src/qt/test/addressbooktests.cpp
index 66637a5dcf..ba0e4c686f 100644
--- a/src/qt/test/addressbooktests.cpp
+++ b/src/qt/test/addressbooktests.cpp
@@ -8,6 +8,7 @@
#include <interfaces/chain.h>
#include <interfaces/node.h>
+#include <qt/addressbookpage.h>
#include <qt/clientmodel.h>
#include <qt/editaddressdialog.h>
#include <qt/optionsmodel.h>
@@ -23,8 +24,9 @@
#include <chrono>
#include <QApplication>
-#include <QTimer>
#include <QMessageBox>
+#include <QTableView>
+#include <QTimer>
using wallet::AddWallet;
using wallet::CWallet;
@@ -131,14 +133,19 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
EditAddressDialog editAddressDialog(EditAddressDialog::NewSendingAddress);
editAddressDialog.setModel(walletModel.getAddressTableModel());
+ AddressBookPage address_book{platformStyle.get(), AddressBookPage::ForEditing, AddressBookPage::SendingTab};
+ address_book.setModel(walletModel.getAddressTableModel());
+ auto table_view = address_book.findChild<QTableView*>("tableView");
+ QCOMPARE(table_view->model()->rowCount(), 1);
+
EditAddressAndSubmit(
&editAddressDialog, QString("uhoh"), preexisting_r_address,
QString(
"Address \"%1\" already exists as a receiving address with label "
"\"%2\" and so cannot be added as a sending address."
).arg(preexisting_r_address).arg(r_label));
-
check_addbook_size(2);
+ QCOMPARE(table_view->model()->rowCount(), 1);
EditAddressAndSubmit(
&editAddressDialog, QString("uhoh, different"), preexisting_s_address,
@@ -146,15 +153,15 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
"The entered address \"%1\" is already in the address book with "
"label \"%2\"."
).arg(preexisting_s_address).arg(s_label));
-
check_addbook_size(2);
+ QCOMPARE(table_view->model()->rowCount(), 1);
// Submit a new address which should add successfully - we expect the
// warning message to be blank.
EditAddressAndSubmit(
&editAddressDialog, QString("new"), new_address, QString(""));
-
check_addbook_size(3);
+ QCOMPARE(table_view->model()->rowCount(), 2);
}
} // namespace
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index 5ee32e79d5..070608ec0b 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -369,7 +369,7 @@ static void NotifyAddressBookChanged(WalletModel *walletmodel,
QString strPurpose = QString::fromStdString(purpose);
qDebug() << "NotifyAddressBookChanged: " + strAddress + " " + strLabel + " isMine=" + QString::number(isMine) + " purpose=" + strPurpose + " status=" + QString::number(status);
- bool invoked = QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection,
+ bool invoked = QMetaObject::invokeMethod(walletmodel, "updateAddressBook",
Q_ARG(QString, strAddress),
Q_ARG(QString, strLabel),
Q_ARG(bool, isMine),