Mercurial > trustbridge
changeset 48:3f8c2d46ded6
Add test for no connection handling
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 17 Mar 2014 11:20:37 +0000 |
parents | 7e37c6033c81 |
children | c389915fd55e |
files | ui/tests/CMakeLists.txt ui/tests/downloadertest.cpp ui/tests/downloadertest.h |
diffstat | 3 files changed, 36 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/ui/tests/CMakeLists.txt Mon Mar 17 11:03:17 2014 +0000 +++ b/ui/tests/CMakeLists.txt Mon Mar 17 11:20:37 2014 +0000 @@ -25,6 +25,11 @@ # so that it can be used in file names in the tests. add_definitions(-DSOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}") add_m13_test(certlistparsertest.cpp "${CERTIFICATELIST_SOURCES}") -add_m13_test(downloadertest.cpp "${DOWNLOADER_SOURCES}") + +# Downloader +set(DOWNLOADER_SOURCES_WITH_RESOURCES ${DOWNLOADER_SOURCES}) +qt5_add_resources(DOWNLOADER_SOURCES_WITH_RESOURCES ${M13UI_RESOURCES}) +add_m13_test(downloadertest.cpp "${DOWNLOADER_SOURCES_WITH_RESOURCES}") + #add_m13_test(${CMAKE_SOURCE_DIR}/ui/main.cpp "${M13UI_SOURCES}")
--- a/ui/tests/downloadertest.cpp Mon Mar 17 11:03:17 2014 +0000 +++ b/ui/tests/downloadertest.cpp Mon Mar 17 11:20:37 2014 +0000 @@ -3,6 +3,7 @@ #include <QTextStream> #include <QFile> +#include <QVariant> #include "unistd.h" void DownloaderTest::startServer(QString additionalOptions) @@ -63,6 +64,33 @@ return retval; } +void DownloaderTest::testNoConnection() +{ + Downloader* downloader = new Downloader(this, + QString::fromLatin1("https://foobar.intevation.de")); + QSignalSpy newListAvailable(downloader, + SIGNAL(newListAvailable(const QString&, const QDateTime&))); + QSignalSpy newSoftwareAvailable(downloader, + SIGNAL(newSoftwareAvailable(const QString&, const QDateTime&))); + QSignalSpy errors(downloader, SIGNAL(error(const QString &, + SSLConnection::ErrorCode))); + downloader->start(); + + int waited = 0; + while (newListAvailable.count() == 0 && + errors.count() == 0 && waited < 20) { + QTest::qWait(200); + waited++; + } + QVERIFY(waited != 20); + + QList<QVariant> arguments = errors.takeFirst(); + + int error = arguments.at(1).toInt(); + + QVERIFY(error == SSLConnection::NoConnection); +} + void DownloaderTest::testNewList() { QFile validCert(QString::fromLatin1(SOURCE_DIR) + @@ -92,7 +120,7 @@ int waited = 0; while (newListAvailable.count() == 0 && errors.count() == 0 && waited < 20) { - QTest::qWait(2000); + QTest::qWait(200); waited++; } QVERIFY(waited != 20);