Mercurial > trustbridge
changeset 55:64200b011dfd
Add test for software download
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Mon, 17 Mar 2014 14:48:20 +0000 |
parents | 09cd242d8443 |
children | 7b0efad494ea |
files | ui/tests/downloadertest.cpp ui/tests/downloadertest.h |
diffstat | 2 files changed, 42 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/ui/tests/downloadertest.cpp Mon Mar 17 14:48:05 2014 +0000 +++ b/ui/tests/downloadertest.cpp Mon Mar 17 14:48:20 2014 +0000 @@ -135,6 +135,47 @@ QVERIFY(error == SSLConnection::NoConnection); } +void DownloaderTest::testNewSoftware() +{ + QFile validCert(QString::fromLatin1(SOURCE_DIR) + + "/data/valid_ssl_bp.pem"); + validCert.open(QIODevice::ReadOnly); + + Downloader* downloader = new Downloader(this, + QString::fromLatin1("https://localhost:44443"), + validCert.readAll(), + QDateTime::fromString("2010", "YYYY"), + QDateTime::currentDateTime(), + "/garbage_2MB", + "/list-valid.txt"); + validCert.close(); + + SETUP_SPY + + connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)), + this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode))); + + downloader->start(); + + int waited = 0; + while (newSoftwareAvailable.count() == 0 && + errors.count() == 0 && waited < 20) { + QTest::qWait(200); + waited++; + } + QVERIFY(waited != 20); + QVERIFY(newListAvailable.count() == 0); + QVERIFY(newSoftwareAvailable.count() == 1); + QVERIFY(errors.count() == 0); + + QList<QVariant> arguments = newSoftwareAvailable.takeFirst(); + + QVERIFY(filesEqual(QString::fromLatin1(SOURCE_DIR) + "/data/garbage_2MB", + arguments.at(0).toString())); + + delete downloader; +} + void DownloaderTest::testNewList() { QFile validCert(QString::fromLatin1(SOURCE_DIR) +