changeset 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 561cc777e0b6
children da6ce90bef17
files CMakeLists.txt ui/CMakeLists.txt ui/mainwindow.cpp ui/tests/downloadertest.cpp ui/tests/downloadertest.h
diffstat 5 files changed, 42 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/CMakeLists.txt	Mon Sep 01 12:53:22 2014 +0200
+++ b/CMakeLists.txt	Mon Sep 01 13:14:10 2014 +0200
@@ -12,6 +12,7 @@
 option(ENABLE_PROFILING "Set to enable profiling." OFF)
 option(USE_CURL "Use libcurl to download updates and certificate lists." ON)
 
+set(DOWNLOAD_SERVER "https://files.intevation.de:443" CACHE STRING "Used as download server" )
 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/")
 
 #Old qtmain linking behavior to be compatible with cmake versions < 2.8.11
--- a/ui/CMakeLists.txt	Mon Sep 01 12:53:22 2014 +0200
+++ b/ui/CMakeLists.txt	Mon Sep 01 13:14:10 2014 +0200
@@ -11,6 +11,9 @@
 include_directories(${CMAKE_BINARY_DIR}/common)
 add_definitions(${Qt5Widgets_DEFINITIONS})
 
+message(STATUS "Using ${DOWNLOAD_SERVER} as download server for updates.")
+add_definitions(-DSERVER_URL="${DOWNLOAD_SERVER}")
+
 find_package(Qt5LinguistTools)
 find_package(CURL)
 
--- a/ui/mainwindow.cpp	Mon Sep 01 12:53:22 2014 +0200
+++ b/ui/mainwindow.cpp	Mon Sep 01 13:14:10 2014 +0200
@@ -55,7 +55,9 @@
 #define APPNAME "TrustBridge"
 #endif
 
-#define SERVER_URL "https://files.intevation.de:443"
+#ifndef SERVER_URL
+#error "DOWNLOAD_SERVER option not set or invalid."
+#endif
 
 #if defined(_X86_) || defined(__i386__)
 #define TB_ARCH_STRING "-i386"
--- 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) +
--- a/ui/tests/downloadertest.h	Mon Sep 01 12:53:22 2014 +0200
+++ b/ui/tests/downloadertest.h	Mon Sep 01 13:14:10 2014 +0200
@@ -37,6 +37,7 @@
     void testOtherCertificate();
     void testNewSoftware();
     void testForcedCiphers();
+    void testDefaultUrl();
 };
 #endif
 

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