comparison ui/tests/downloadertest.cpp @ 55:64200b011dfd

Add test for software download
author Andre Heinecke <aheinecke@intevation.de>
date Mon, 17 Mar 2014 14:48:20 +0000
parents d73a2f0170d4
children c05e126b0b9e
comparison
equal deleted inserted replaced
54:09cd242d8443 55:64200b011dfd
133 int error = arguments.at(1).toInt(); 133 int error = arguments.at(1).toInt();
134 134
135 QVERIFY(error == SSLConnection::NoConnection); 135 QVERIFY(error == SSLConnection::NoConnection);
136 } 136 }
137 137
138 void DownloaderTest::testNewSoftware()
139 {
140 QFile validCert(QString::fromLatin1(SOURCE_DIR) +
141 "/data/valid_ssl_bp.pem");
142 validCert.open(QIODevice::ReadOnly);
143
144 Downloader* downloader = new Downloader(this,
145 QString::fromLatin1("https://localhost:44443"),
146 validCert.readAll(),
147 QDateTime::fromString("2010", "YYYY"),
148 QDateTime::currentDateTime(),
149 "/garbage_2MB",
150 "/list-valid.txt");
151 validCert.close();
152
153 SETUP_SPY
154
155 connect(downloader, SIGNAL(error(const QString &, SSLConnection::ErrorCode)),
156 this, SLOT(downloaderError(const QString &, SSLConnection::ErrorCode)));
157
158 downloader->start();
159
160 int waited = 0;
161 while (newSoftwareAvailable.count() == 0 &&
162 errors.count() == 0 && waited < 20) {
163 QTest::qWait(200);
164 waited++;
165 }
166 QVERIFY(waited != 20);
167 QVERIFY(newListAvailable.count() == 0);
168 QVERIFY(newSoftwareAvailable.count() == 1);
169 QVERIFY(errors.count() == 0);
170
171 QList<QVariant> arguments = newSoftwareAvailable.takeFirst();
172
173 QVERIFY(filesEqual(QString::fromLatin1(SOURCE_DIR) + "/data/garbage_2MB",
174 arguments.at(0).toString()));
175
176 delete downloader;
177 }
178
138 void DownloaderTest::testNewList() 179 void DownloaderTest::testNewList()
139 { 180 {
140 QFile validCert(QString::fromLatin1(SOURCE_DIR) + 181 QFile validCert(QString::fromLatin1(SOURCE_DIR) +
141 "/data/valid_ssl_bp.pem"); 182 "/data/valid_ssl_bp.pem");
142 validCert.open(QIODevice::ReadOnly); 183 validCert.open(QIODevice::ReadOnly);

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