Mercurial > trustbridge
diff ui/tests/downloadertest.cpp @ 240:c05e126b0b9e
Fix downloadertest and factor out generating file input.
author | Andre Heinecke <aheinecke@intevation.de> |
---|---|
date | Fri, 28 Mar 2014 15:21:02 +0000 |
parents | 64200b011dfd |
children | 17e1c8f37d72 |
line wrap: on
line diff
--- a/ui/tests/downloadertest.cpp Fri Mar 28 14:20:08 2014 +0000 +++ b/ui/tests/downloadertest.cpp Fri Mar 28 15:21:02 2014 +0000 @@ -1,10 +1,11 @@ #include "downloadertest.h" #include "downloader.h" +#include "common.h" #include <QTextStream> #include <QFile> #include <QVariant> -#include "unistd.h" +#include <unistd.h> #define MAX_WAIT 20 @@ -28,7 +29,6 @@ mimeConfig.close(); /* just an empty file */ QTextStream configStream(&serverConfig); - qDebug() << "Config file name: " << serverConfig.fileName(); configStream << "Binding { " << endl << "Port = 44443 " << endl << @@ -37,7 +37,7 @@ "Interface = 127.0.0.1" << endl << "}" << endl << "Hostname = 127.0.0.1" << endl << - "WebsiteRoot = " << SOURCE_DIR << "/data" << endl; + "WebsiteRoot = " << serverConfigDir.path() << endl; configStream.flush(); serverConfig.close(); @@ -52,6 +52,10 @@ serverProc.setArguments(arguments); qRegisterMetaType<SSLConnection::ErrorCode>("SSLConnection::ErrorCode"); startServer(); + garbageInfo = QFileInfo(getRandomDataFile(2 * 1024, serverConfigDir.path())); + QVERIFY(QFile::copy(QString::fromLocal8Bit(SOURCE_DIR"/data/list-valid.txt"), + serverConfigDir.path() + "/" + "list-valid.txt")); + QTest::qWait(1000); /* Wait for the server to settle */ } @@ -80,12 +84,14 @@ "/data/valid_ssl_rsa.pem"); otherCert.open(QIODevice::ReadOnly); + QFileInfo fi(getRandomDataFile(200)); + Downloader* downloader = new Downloader(this, QString::fromLatin1("https://localhost:44443"), otherCert.readAll(), QDateTime::currentDateTime(), // Last installed SW QDateTime::fromString("2010", "YYYY"), - "/garbage_2MB", + "/" + garbageInfo.fileName(), "/list-valid.txt"); otherCert.close(); @@ -146,7 +152,7 @@ validCert.readAll(), QDateTime::fromString("2010", "YYYY"), QDateTime::currentDateTime(), - "/garbage_2MB", + "/" + garbageInfo.fileName(), "/list-valid.txt"); validCert.close(); @@ -170,7 +176,7 @@ QList<QVariant> arguments = newSoftwareAvailable.takeFirst(); - QVERIFY(filesEqual(QString::fromLatin1(SOURCE_DIR) + "/data/garbage_2MB", + QVERIFY(filesEqual(serverConfigDir.path() + "/" + garbageInfo.fileName(), arguments.at(0).toString())); delete downloader; @@ -187,7 +193,7 @@ validCert.readAll(), QDateTime::currentDateTime(), // Last installed SW QDateTime::fromString("2010", "YYYY"), - "/garbage_2MB", + "/" + garbageInfo.fileName(), "/list-valid.txt"); validCert.close();