comparison 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
comparison
equal deleted inserted replaced
46:d28e2624c1d5 47:7e37c6033c81
47 void DownloaderTest::downloaderError(const QString &message, SSLConnection::ErrorCode error) 47 void DownloaderTest::downloaderError(const QString &message, SSLConnection::ErrorCode error)
48 { 48 {
49 qDebug() << "Downloader Error: " << error << " Msg: " << message; 49 qDebug() << "Downloader Error: " << error << " Msg: " << message;
50 } 50 }
51 51
52 bool filesEqual(QString filename1, QString filename2)
53 {
54 bool retval = false;
55 QFile file1(filename1);
56 QFile file2(filename2);
57 file1.open(QIODevice::ReadOnly);
58 file2.open(QIODevice::ReadOnly);
59
60 retval = (file1.readAll() == file2.readAll());
61 file1.close();
62 file2.close();
63 return retval;
64 }
65
52 void DownloaderTest::testNewList() 66 void DownloaderTest::testNewList()
53 { 67 {
54 QFile validCert(QString::fromLatin1(SOURCE_DIR) + 68 QFile validCert(QString::fromLatin1(SOURCE_DIR) +
55 "/data/valid_ssl_bp.pem"); 69 "/data/valid_ssl_bp.pem");
56 validCert.open(QIODevice::ReadOnly); 70 validCert.open(QIODevice::ReadOnly);
83 } 97 }
84 QVERIFY(waited != 20); 98 QVERIFY(waited != 20);
85 QVERIFY(newListAvailable.count() == 1); 99 QVERIFY(newListAvailable.count() == 1);
86 QVERIFY(newSoftwareAvailable.count() == 0); 100 QVERIFY(newSoftwareAvailable.count() == 0);
87 QVERIFY(errors.count() == 0); 101 QVERIFY(errors.count() == 0);
102
103 QList<QVariant> arguments = newListAvailable.takeFirst();
104
105 QVERIFY(filesEqual(QString::fromLatin1(SOURCE_DIR) + "/data/list-valid.txt",
106 arguments.at(0).toString()));
107
88 delete downloader; 108 delete downloader;
89 } 109 }
90 110
91 void DownloaderTest::cleanupTestCase() { 111 void DownloaderTest::cleanupTestCase() {
92 if (serverProc.state() == QProcess::Running) { 112 if (serverProc.state() == QProcess::Running) {

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