diff ui/tests/downloadertest.cpp @ 47:7e37c6033c81

Verify that the downloaded file matches the served one
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 17 Mar 2014 11:03:17 +0000
parents d28e2624c1d5
children 3f8c2d46ded6
line wrap: on
line diff
--- a/ui/tests/downloadertest.cpp	Mon Mar 17 10:51:47 2014 +0000
+++ b/ui/tests/downloadertest.cpp	Mon Mar 17 11:03:17 2014 +0000
@@ -49,6 +49,20 @@
     qDebug() << "Downloader Error: " << error << " Msg: " << message;
 }
 
+bool filesEqual(QString filename1, QString filename2)
+{
+    bool retval = false;
+    QFile file1(filename1);
+    QFile file2(filename2);
+    file1.open(QIODevice::ReadOnly);
+    file2.open(QIODevice::ReadOnly);
+
+    retval = (file1.readAll() == file2.readAll());
+    file1.close();
+    file2.close();
+    return retval;
+}
+
 void DownloaderTest::testNewList()
 {
     QFile validCert(QString::fromLatin1(SOURCE_DIR) +
@@ -85,6 +99,12 @@
     QVERIFY(newListAvailable.count() == 1);
     QVERIFY(newSoftwareAvailable.count() == 0);
     QVERIFY(errors.count() == 0);
+
+    QList<QVariant> arguments = newListAvailable.takeFirst();
+
+    QVERIFY(filesEqual(QString::fromLatin1(SOURCE_DIR) + "/data/list-valid.txt",
+        arguments.at(0).toString()));
+
     delete downloader;
 }
 

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