diff ui/tests/downloadertest.cpp @ 994:8fb1b912fd8e

Add test using the default download server used by the software This should help to highlight problems in the real environement but needs to be adapted when the server / server layout changes just as the software..
author Andre Heinecke <andre.heinecke@intevation.de>
date Mon, 01 Sep 2014 13:14:10 +0200
parents 2949f1842955
children daa9448b64f5
line wrap: on
line diff
--- a/ui/tests/downloadertest.cpp	Mon Sep 01 12:53:22 2014 +0200
+++ b/ui/tests/downloadertest.cpp	Mon Sep 01 13:14:10 2014 +0200
@@ -228,6 +228,40 @@
     delete downloader;
 }
 
+void DownloaderTest::testDefaultUrl()
+{
+    /* This test might fail if SERVER_URL is configured differently
+     * and needs to be adapted once there is a public download server. 
+     * This test also needs internet connectivity. */
+    Downloader* downloader = new Downloader(this,
+            QString::fromLatin1(SERVER_URL),
+            QByteArray(),
+            QDateTime::currentDateTime(), // Last installed SW
+            QDateTime::fromString("2010", "YYYY"),
+            QString("/users/aheinecke/zertifikatsliste.txt"),
+            QString("/users/aheinecke/zertifikatsliste.txt"));
+
+    SETUP_SPY
+
+    connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)),
+            this, SLOT(downloaderError(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);
+    QVERIFY(newListAvailable.count() == 1);
+    QVERIFY(newSoftwareAvailable.count() == 0);
+    QVERIFY(errors.count() == 0);
+
+    delete downloader;
+}
+
 void DownloaderTest::testNewList()
 {
     QFile validCert(QString::fromLatin1(SOURCE_DIR) +

http://wald.intevation.org/projects/trustbridge/