Skip to content

Commit 3dd95cb

Browse files
committed
Merge #591: test: Add tests for tableView in AddressBookPage dialog
1506913 qt, test: Add tests for `tableView` in `AddressBookPage` dialog (Hennadii Stepanov) edae3ab 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 #578 and #585. Required for #592. ACKs for top commit: promag: Code review ACK 1506913. Tree-SHA512: 86986d47606cbd54d813436c7afb21894e2200b6d3042a7aa0b5e84821c765bd68b14ad38a445069891ab33f2d7bcd4933b8373e14e9afb0c91f1a6ddf4da740
2 parents a8098f2 + 1506913 commit 3dd95cb

File tree

2 files changed

+12
-5
lines changed

2 files changed

+12
-5
lines changed

src/qt/test/addressbooktests.cpp

+11-4
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include <interfaces/chain.h>
1010
#include <interfaces/node.h>
11+
#include <qt/addressbookpage.h>
1112
#include <qt/clientmodel.h>
1213
#include <qt/editaddressdialog.h>
1314
#include <qt/optionsmodel.h>
@@ -23,8 +24,9 @@
2324
#include <chrono>
2425

2526
#include <QApplication>
26-
#include <QTimer>
2727
#include <QMessageBox>
28+
#include <QTableView>
29+
#include <QTimer>
2830

2931
using wallet::AddWallet;
3032
using wallet::CWallet;
@@ -131,30 +133,35 @@ void TestAddAddressesToSendBook(interfaces::Node& node)
131133
EditAddressDialog editAddressDialog(EditAddressDialog::NewSendingAddress);
132134
editAddressDialog.setModel(walletModel.getAddressTableModel());
133135

136+
AddressBookPage address_book{platformStyle.get(), AddressBookPage::ForEditing, AddressBookPage::SendingTab};
137+
address_book.setModel(walletModel.getAddressTableModel());
138+
auto table_view = address_book.findChild<QTableView*>("tableView");
139+
QCOMPARE(table_view->model()->rowCount(), 1);
140+
134141
EditAddressAndSubmit(
135142
&editAddressDialog, QString("uhoh"), preexisting_r_address,
136143
QString(
137144
"Address \"%1\" already exists as a receiving address with label "
138145
"\"%2\" and so cannot be added as a sending address."
139146
).arg(preexisting_r_address).arg(r_label));
140-
141147
check_addbook_size(2);
148+
QCOMPARE(table_view->model()->rowCount(), 1);
142149

143150
EditAddressAndSubmit(
144151
&editAddressDialog, QString("uhoh, different"), preexisting_s_address,
145152
QString(
146153
"The entered address \"%1\" is already in the address book with "
147154
"label \"%2\"."
148155
).arg(preexisting_s_address).arg(s_label));
149-
150156
check_addbook_size(2);
157+
QCOMPARE(table_view->model()->rowCount(), 1);
151158

152159
// Submit a new address which should add successfully - we expect the
153160
// warning message to be blank.
154161
EditAddressAndSubmit(
155162
&editAddressDialog, QString("new"), new_address, QString(""));
156-
157163
check_addbook_size(3);
164+
QCOMPARE(table_view->model()->rowCount(), 2);
158165
}
159166

160167
} // namespace

src/qt/walletmodel.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ static void NotifyAddressBookChanged(WalletModel *walletmodel,
369369
QString strPurpose = QString::fromStdString(purpose);
370370

371371
qDebug() << "NotifyAddressBookChanged: " + strAddress + " " + strLabel + " isMine=" + QString::number(isMine) + " purpose=" + strPurpose + " status=" + QString::number(status);
372-
bool invoked = QMetaObject::invokeMethod(walletmodel, "updateAddressBook", Qt::QueuedConnection,
372+
bool invoked = QMetaObject::invokeMethod(walletmodel, "updateAddressBook",
373373
Q_ARG(QString, strAddress),
374374
Q_ARG(QString, strLabel),
375375
Q_ARG(bool, isMine),

0 commit comments

Comments
 (0)