diff options
Diffstat (limited to 'src/qt/test')
| -rw-r--r-- | src/qt/test/Makefile.am | 33 | ||||
| -rw-r--r-- | src/qt/test/paymentservertests.cpp | 14 | ||||
| -rw-r--r-- | src/qt/test/paymentservertests.h | 2 | ||||
| -rw-r--r-- | src/qt/test/test_main.cpp | 24 |
4 files changed, 59 insertions, 14 deletions
diff --git a/src/qt/test/Makefile.am b/src/qt/test/Makefile.am index 7891c3e97..2461b5ff4 100644 --- a/src/qt/test/Makefile.am +++ b/src/qt/test/Makefile.am @@ -8,18 +8,39 @@ AM_CPPFLAGS += -I$(top_srcdir)/src \ bin_PROGRAMS = test_bitcoin-qt TESTS = test_bitcoin-qt -TEST_QT_MOC_CPP = moc_uritests.cpp moc_paymentservertests.cpp +TEST_QT_MOC_CPP = moc_uritests.cpp -TEST_QT_H = uritests.h paymentservertests.h paymentrequestdata.h +if ENABLE_WALLET +TEST_QT_MOC_CPP += moc_paymentservertests.cpp +endif + +TEST_QT_H = \ + uritests.h \ + paymentrequestdata.h \ + paymentservertests.h BUILT_SOURCES = $(TEST_QT_MOC_CPP) test_bitcoin_qt_CPPFLAGS = $(AM_CPPFLAGS) $(QT_INCLUDES) $(QT_TEST_INCLUDES) -test_bitcoin_qt_SOURCES = test_main.cpp uritests.cpp paymentservertests.cpp $(TEST_QT_H) + +test_bitcoin_qt_SOURCES = \ + test_main.cpp \ + uritests.cpp \ + $(TEST_QT_H) +if ENABLE_WALLET +test_bitcoin_qt_SOURCES += \ + paymentservertests.cpp +endif + nodist_test_bitcoin_qt_SOURCES = $(TEST_QT_MOC_CPP) -test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN) $(LIBLEVELDB) \ - $(LIBMEMENV) $(BOOST_LIBS) $(QT_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) \ + +test_bitcoin_qt_LDADD = $(LIBBITCOINQT) $(LIBBITCOIN_SERVER) +if ENABLE_WALLET +test_bitcoin_qt_LDADD += $(LIBBITCOIN_WALLET) +endif +test_bitcoin_qt_LDADD += $(LIBBITCOIN_CLI) $(LIBBITCOIN_COMMON) $(LIBLEVELDB) \ + $(LIBMEMENV) $(BOOST_LIBS) $(QT_DBUS_LIBS) $(QT_TEST_LIBS) $(QT_LIBS) \ $(QR_LIBS) $(PROTOBUF_LIBS) $(BDB_LIBS) +test_bitcoin_qt_LDFLAGS = $(QT_LDFLAGS) CLEANFILES = $(BUILT_SOURCES) *.gcda *.gcno - diff --git a/src/qt/test/paymentservertests.cpp b/src/qt/test/paymentservertests.cpp index b8f2cc65c..7dee7a9cd 100644 --- a/src/qt/test/paymentservertests.cpp +++ b/src/qt/test/paymentservertests.cpp @@ -7,12 +7,9 @@ #include <openssl/x509.h> #include <openssl/x509_vfy.h> -#include <QCoreApplication> -#include <QDebug> + #include <QFileOpenEvent> #include <QTemporaryFile> -#include <QVariant> - X509 *parse_b64der_cert(const char* cert_data) { @@ -41,9 +38,14 @@ static SendCoinsRecipient handleRequest(PaymentServer* server, std::vector<unsig f.write((const char*)&data[0], data.size()); f.close(); - // Create a FileOpenEvent and send it directly to the server's event filter: + // Create a QObject, install event filter from PaymentServer + // and send a file open event to the object + QObject object; + object.installEventFilter(server); QFileOpenEvent event(f.fileName()); - server->eventFilter(NULL, &event); + // If sending the event fails, this will cause sigCatcher to be empty, + // which will lead to a test failure anyway. + QCoreApplication::sendEvent(&object, &event); QObject::disconnect(server, SIGNAL(receivedPaymentRequest(SendCoinsRecipient)), &sigCatcher, SLOT(getRecipient(SendCoinsRecipient))); diff --git a/src/qt/test/paymentservertests.h b/src/qt/test/paymentservertests.h index 0bff923ad..884e535a6 100644 --- a/src/qt/test/paymentservertests.h +++ b/src/qt/test/paymentservertests.h @@ -20,8 +20,10 @@ private slots: class RecipientCatcher : public QObject { Q_OBJECT + public slots: void getRecipient(SendCoinsRecipient r); + public: SendCoinsRecipient recipient; }; diff --git a/src/qt/test/test_main.cpp b/src/qt/test/test_main.cpp index 5c941c638..a2adb0032 100644 --- a/src/qt/test/test_main.cpp +++ b/src/qt/test/test_main.cpp @@ -1,23 +1,43 @@ +#include "bitcoin-config.h" +#if defined(HAVE_CONFIG_H) +#include "bitcoin-config.h" +#endif - +#ifdef ENABLE_WALLET #include "paymentservertests.h" +#endif #include "uritests.h" +#include <QCoreApplication> #include <QObject> #include <QTest> +#if defined(QT_STATICPLUGIN) && QT_VERSION < 0x050000 +#include <QtPlugin> +Q_IMPORT_PLUGIN(qcncodecs) +Q_IMPORT_PLUGIN(qjpcodecs) +Q_IMPORT_PLUGIN(qtwcodecs) +Q_IMPORT_PLUGIN(qkrcodecs) +#endif + // This is all you need to run all the tests int main(int argc, char *argv[]) { bool fInvalid = false; + // Don't remove this, it's needed to access + // QCoreApplication:: in the tests + QCoreApplication app(argc, argv); + app.setApplicationName("Bitcoin-Qt-test"); + URITests test1; if (QTest::qExec(&test1) != 0) fInvalid = true; - +#ifdef ENABLE_WALLET PaymentServerTests test2; if (QTest::qExec(&test2) != 0) fInvalid = true; +#endif return fInvalid; } |