This adds a basic unit test for the Qt send coins dialog. I have more changes (for a future PR) that extend this to cover new Qt bumpfee code in #9697.
Previously, I brought up the topic of qt unit tests in #9817 (comment) and #9697 (review).
This adds a basic unit test for the Qt send coins dialog. I have more changes (for a future PR) that extend this to cover new Qt bumpfee code in #9697.
Previously, I brought up the topic of qt unit tests in #9817 (comment) and #9697 (review).
Move Boost.Test main function and global overrides to a new test_bitcoin_main.cpp file.
Reset global state after rpc tests, and remove unnecessary ECC initialization
to prevent assert error if it is initialized twice.
Failed with:
0==============================================
1 Bitcoin Core 0.14.99: src/test-suite.log
2==============================================
3# TOTAL: 2
4# PASS: 1
5# SKIP: 0
6# XFAIL: 0
7# FAIL: 1
8# XPASS: 0
9# ERROR: 0
10.. contents:: :depth: 2
11FAIL: qt/test/test_bitcoin-qt
12=============================
13This application failed to start because it could not find or load the Qt platform plugin "xcb"
14in "".
15Reinstalling the application may fix this problem.
I’d prefer a solution that runs on a higher abstraction level. Your current approach is pretty much mimicking functional tests on a low (unit test) level.
I don’t think I understand. I’m not doing anything original here, just following the approach of http://doc.qt.io/qt-5/qttestlib-tutorial3-example.html.
Is it that instead of the writing a test that sends qt events, you would prefer to see a test that starts an x server and sends keyboard and mouse events?
Is it that instead of the writing a test that sends qt events, you would prefer to see a test that starts an x server and sends keyboard and mouse events?
Indeed. I was dreaming of a gui test framework where you just press a “record this” button. Then records discrete actions (e.g. “Press: Receive tab”, “Press: Copy address”, other gui: “Press: Send tab”, “Insert: $address”, …) instead of the exact mouse and keyboard movements, such that it works on different screen resolutions. Though, we also need a way to wait for the gui to catch up on longer tasks such as importmulti with rescan, so I don’t think this is a weekend project.
On Sat, Mar 11, 2017 at 12:36 PM, Jonas Schnelli notifications@github.com wrote:
I really like this. Concept ACK.
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/bitcoin/bitcoin/pull/9974#issuecomment-285861292, or mute the thread https://github.com/notifications/unsubscribe-auth/AGGmv2gRizL47AbknwIa11DdwdLFQFBrks5rkoc4gaJpZM4MZ6Pd .
44@@ -46,7 +45,7 @@ int main(int argc, char *argv[])
45
46 // Don't remove this, it's needed to access
47 // QCoreApplication:: in the tests
63@@ -65,7 +64,11 @@ int main(int argc, char *argv[])
64 CompatTests test4;
65 if (QTest::qExec(&test4) != 0)
66 fInvalid = true;
67+#ifdef ENABLE_WALLET
68+ WalletTests test5;
69+ if (QTest::qExec(&test5) != 0)
Avoids following error when qt is statically linked into the test binary, as on
travis:
This application failed to start because it could not find or load the Qt platform plugin "xcb"
in "".
Avoids following error:
QXcbConnection: Could not connect to display
A lock is missing.
0diff --git a/src/qt/test/wallettests.cpp b/src/qt/test/wallettests.cpp
1index 81b358e..d63f4ec 100644
2--- a/src/qt/test/wallettests.cpp
3+++ b/src/qt/test/wallettests.cpp
4@@ -73,6 +73,7 @@ void WalletTests::walletTests()
5 test.CreateAndProcessBlock({}, GetScriptForRawPubKey(test.coinbaseKey.GetPubKey()));
6 bitdb.MakeMock();
7 CWallet wallet("wallet_test.dat");
8+ LOCK(wallet.cs_wallet);
9 bool firstRun;
10 wallet.LoadWallet(firstRun);
11 wallet.SetAddressBook(test.coinbaseKey.GetPubKey().GetID(), "", "receive");
How could this pass travis with the missing lock?
Will properly ACK after apply the diff above.
Question: is it possible to create a screenshot (or a bitmap/JPG/PNG) of the UI elements you open? A such form of an UI export would be great. We could add this then to a CI and have plenty of screenshots from various operating systems in order to verify the UI correctness.
A lock is missing.
Will add. I’m not sure the way the lock is acquired in the diff is exactly right, because cs_main is supported to be acquired before cs_wallet, and some wallet methods acquire both.
How could this pass travis with the missing lock?
Locally, the test works fine for me with the missing lock. On travis, every configuration we have either specifies NO_QT or NO_WALLET, or omits RUN_TESTS, so neither PaymentServerTests code nor this new WalletTests code currently executes.
Question: is it possible to create a screenshot (or a bitmap/JPG/PNG) of the UI elements you open? A such form of an UI export would be great. We could add this then to a CI and have plenty of screenshots from various operating systems in order to verify the UI correctness.
Something like this should be possible. To help debug this change, I frequently added widget.show(); QEventLoop().exec();
calls to be able to see and interact with individual test widgets, so it should be possible to capture images also (maybe with QWidget::grab?)
Fixed locking bug in 739f19ca969c2ae351e18d2bbb424237830f54f1
Squashed 739f19ca969c2ae351e18d2bbb424237830f54f1 -> 9576b015a107b98fc950c574ed01d993b388d7c9 (pr/qt-test.7 -> pr/qt-test.8)
This is great. Hopefully I’ll have coverage running soon so we can see how much extra code you’ve managed to exercise.
Post-merge tested ACK https://github.com/bitcoin/bitcoin/commit/9576b015a107b98fc950c574ed01d993b388d7c9.
BTW, compiling this is not possible with gcc-4.8.5, the default gcc on openSUSE 42.2:
0/usr/include/boost/signals2/connection.hpp: In function 'uint256 {anonymous}::SendCoins(CWallet&, SendCoinsDialog&, const CBitcoinAddress&, CAmount)':
1/usr/include/boost/signals2/connection.hpp:234:7: error: 'boost::signals2::scoped_connection::scoped_connection(const boost::signals2::scoped_connection&)' is private
2 scoped_connection(const scoped_connection &other);
3 ^
4qt/test/wallettests.cpp:47:6: error: within this context
5 });
6 ^
7Makefile:7991: recipe for target 'qt/test/qt_test_test_bitcoin_qt-wallettests.o' failed
8make[2]: *** [qt/test/qt_test_test_bitcoin_qt-wallettests.o] Error 1
Possible fix might be to change:
0boost::signals2::scoped_connection c = wallet.NotifyTransactionChanged.connect(...);
to:
0boost::signals2::scoped_connection c(wallet.NotifyTransactionChanged.connect(...));
And another issue here. On plain Debian Jessie, with the gcc version 4.9.2 (Debian 4.9.2-10), this doesn’t compile with:
0qt/test/wallettests.cpp:34:6: error: no matching function for call to 'QTimer::singleShot(int, Qt::TimerType, {anonymous}::ConfirmSend()::<lambda()>)'
1 });
2 ^
3qt/test/wallettests.cpp:34:6: note: candidates are:
4In file included from /usr/include/x86_64-linux-gnu/qt5/QtCore/QTimer:1:0,
5 from ./qt/sendcoinsdialog.h:13,
6 from qt/test/wallettests.cpp:7:
7/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:81:17: note: static void QTimer::singleShot(int, const QObject*, const char*)
8 static void singleShot(int msec, const QObject *receiver, const char *member);
9 ^
10/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:81:17: note: no known conversion for argument 2 from 'Qt::TimerType' to 'const QObject*'
11/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:82:17: note: static void QTimer::singleShot(int, Qt::TimerType, const QObject*, const char*)
12 static void singleShot(int msec, Qt::TimerType timerType, const QObject *receiver, const char *member);
13 ^
14/usr/include/x86_64-linux-gnu/qt5/QtCore/qtimer.h:82:17: note: candidate expects 4 arguments, 3 provided
15Makefile:7991: recipe for target 'qt/test/qt_test_test_bitcoin_qt-wallettests.o' failed
16make[2]: *** [qt/test/qt_test_test_bitcoin_qt-wallettests.o] Error 1