13
13
#include " test/test_bitcoin.h"
14
14
#include " validation.h"
15
15
#include " wallet/wallet.h"
16
+ #include " qt/overviewpage.h"
17
+ #include " qt/receivecoinsdialog.h"
18
+ #include " qt/recentrequeststablemodel.h"
19
+ #include " qt/receiverequestdialog.h"
16
20
17
21
#include < QAbstractButton>
18
22
#include < QAction>
21
25
#include < QPushButton>
22
26
#include < QTimer>
23
27
#include < QVBoxLayout>
28
+ #include < QTextEdit>
29
+ #include < QListView>
30
+ #include < QDialogButtonBox>
24
31
25
32
namespace
26
33
{
@@ -140,7 +147,7 @@ void BumpFee(TransactionView& view, const uint256& txid, bool expectDisabled, st
140
147
// src/qt/test/test_bitcoin-qt -platform xcb # Linux
141
148
// src/qt/test/test_bitcoin-qt -platform windows # Windows
142
149
// src/qt/test/test_bitcoin-qt -platform cocoa # macOS
143
- void TestSendCoins ()
150
+ void TestGUI ()
144
151
{
145
152
// Set up wallet and chain with 105 blocks (5 mature blocks for spending).
146
153
TestChain100Setup test;
@@ -184,6 +191,68 @@ void TestSendCoins()
184
191
BumpFee (transactionView, txid2, false /* expect disabled */ , {} /* expected error */ , false /* cancel */ );
185
192
BumpFee (transactionView, txid2, true /* expect disabled */ , " already bumped" /* expected error */ , false /* cancel */ );
186
193
194
+ // Check current balance on OverviewPage
195
+ OverviewPage overviewPage (platformStyle.get ());
196
+ overviewPage.setWalletModel (&walletModel);
197
+ QLabel* balanceLabel = overviewPage.findChild <QLabel*>(" labelBalance" );
198
+ QString balanceText = balanceLabel->text ();
199
+ int unit = walletModel.getOptionsModel ()->getDisplayUnit ();
200
+ CAmount balance = walletModel.getBalance ();
201
+ QString balanceComparison = BitcoinUnits::formatWithUnit (unit, balance, false , BitcoinUnits::separatorAlways);
202
+ QCOMPARE (balanceText, balanceComparison);
203
+
204
+ // Check Request Payment button
205
+ ReceiveCoinsDialog receiveCoinsDialog (platformStyle.get ());
206
+ receiveCoinsDialog.setModel (&walletModel);
207
+ RecentRequestsTableModel* requestTableModel = walletModel.getRecentRequestsTableModel ();
208
+
209
+ // Label input
210
+ QLineEdit* labelInput = receiveCoinsDialog.findChild <QLineEdit*>(" reqLabel" );
211
+ labelInput->setText (" TEST_LABEL_1" );
212
+
213
+ // Amount input
214
+ BitcoinAmountField* amountInput = receiveCoinsDialog.findChild <BitcoinAmountField*>(" reqAmount" );
215
+ amountInput->setValue (1 );
216
+
217
+ // Message input
218
+ QLineEdit* messageInput = receiveCoinsDialog.findChild <QLineEdit*>(" reqMessage" );
219
+ messageInput->setText (" TEST_MESSAGE_1" );
220
+ int initialRowCount = requestTableModel->rowCount ({});
221
+ QPushButton* requestPaymentButton = receiveCoinsDialog.findChild <QPushButton*>(" receiveButton" );
222
+ requestPaymentButton->click ();
223
+ for (QWidget* widget : QApplication::topLevelWidgets ()) {
224
+ if (widget->inherits (" ReceiveRequestDialog" )) {
225
+ ReceiveRequestDialog* receiveRequestDialog = qobject_cast<ReceiveRequestDialog*>(widget);
226
+ QTextEdit* rlist = receiveRequestDialog->QObject ::findChild<QTextEdit*>(" outUri" );
227
+ QString paymentText = rlist->toPlainText ();
228
+ QStringList paymentTextList = paymentText.split (' \n ' );
229
+ QCOMPARE (paymentTextList.at (0 ), QString (" Payment information" ));
230
+ QVERIFY (paymentTextList.at (1 ).indexOf (QString (" URI: bitcoin:" )) != -1 );
231
+ QVERIFY (paymentTextList.at (2 ).indexOf (QString (" Address:" )) != -1 );
232
+ QCOMPARE (paymentTextList.at (3 ), QString (" Amount: 0.00000001 " ) + QString::fromStdString (CURRENCY_UNIT));
233
+ QCOMPARE (paymentTextList.at (4 ), QString (" Label: TEST_LABEL_1" ));
234
+ QCOMPARE (paymentTextList.at (5 ), QString (" Message: TEST_MESSAGE_1" ));
235
+ }
236
+ }
237
+
238
+ // Clear button
239
+ QPushButton* clearButton = receiveCoinsDialog.findChild <QPushButton*>(" clearButton" );
240
+ clearButton->click ();
241
+ QCOMPARE (labelInput->text (), QString (" " ));
242
+ QCOMPARE (amountInput->value (), CAmount (0 ));
243
+ QCOMPARE (messageInput->text (), QString (" " ));
244
+
245
+ // Check addition to history
246
+ int currentRowCount = requestTableModel->rowCount ({});
247
+ QCOMPARE (currentRowCount, initialRowCount+1 );
248
+
249
+ // Check Remove button
250
+ QTableView* table = receiveCoinsDialog.findChild <QTableView*>(" recentRequestsView" );
251
+ table->selectRow (currentRowCount-1 );
252
+ QPushButton* removeRequestButton = receiveCoinsDialog.findChild <QPushButton*>(" removeRequestButton" );
253
+ removeRequestButton->click ();
254
+ QCOMPARE (requestTableModel->rowCount ({}), currentRowCount-1 );
255
+
187
256
bitdb.Flush (true );
188
257
bitdb.Reset ();
189
258
}
@@ -192,5 +261,5 @@ void TestSendCoins()
192
261
193
262
void WalletTests::walletTests ()
194
263
{
195
- TestSendCoins ();
264
+ TestGUI ();
196
265
}
0 commit comments