Changeset View
Changeset View
Standalone View
Standalone View
autotests/server/partstreamertest.cpp
Show First 20 Lines • Show All 245 Lines • ▼ Show 20 Line(s) | 239 | if (storage == Part::External) { | |||
---|---|---|---|---|---|
246 | const QByteArray fileData = file.readAll(); | 246 | const QByteArray fileData = file.readAll(); | ||
247 | QCOMPARE(fileData, expectedFileData); | 247 | QCOMPARE(fileData, expectedFileData); | ||
248 | 248 | | |||
249 | // Make sure no previous versions are left behind in file_db_data | 249 | // Make sure no previous versions are left behind in file_db_data | ||
250 | const int revision = data.mid(data.indexOf("_r") + 2).toInt(); | 250 | const int revision = data.mid(data.indexOf("_r") + 2).toInt(); | ||
251 | for (int i = 0; i < revision; ++i) { | 251 | for (int i = 0; i < revision; ++i) { | ||
252 | const QByteArray fileName = QByteArray::number(part.id()) + "_r" + QByteArray::number(i); | 252 | const QByteArray fileName = QByteArray::number(part.id()) + "_r" + QByteArray::number(i); | ||
253 | const QString filePath = ExternalPartStorage::resolveAbsolutePath(fileName); | 253 | const QString filePath = ExternalPartStorage::resolveAbsolutePath(fileName); | ||
254 | QVERIFY2(!QFile::exists(filePath), qPrintable(filePath)); | 254 | // TRY because the deletion happens in another thread | ||
255 | QTRY_VERIFY2(!QFile::exists(filePath), qPrintable(filePath)); | ||||
255 | } | 256 | } | ||
256 | } else if (storage == Part::Foreign) { | 257 | } else if (storage == Part::Foreign) { | ||
257 | QCOMPARE(data, expectedPartData); | 258 | QCOMPARE(data, expectedPartData); | ||
258 | QFile file(QString::fromUtf8(data)); | 259 | QFile file(QString::fromUtf8(data)); | ||
259 | QVERIFY(file.exists()); | 260 | QVERIFY(file.exists()); | ||
260 | QCOMPARE(file.size(), expectedPartSize); | 261 | QCOMPARE(file.size(), expectedPartSize); | ||
261 | QVERIFY(file.open(QIODevice::ReadOnly)); | 262 | QVERIFY(file.open(QIODevice::ReadOnly)); | ||
262 | 263 | | |||
263 | const QByteArray fileData = file.readAll(); | 264 | const QByteArray fileData = file.readAll(); | ||
264 | QCOMPARE(fileData, expectedFileData); | 265 | QCOMPARE(fileData, expectedFileData); | ||
265 | } else { | 266 | } else { | ||
266 | QCOMPARE(data, expectedPartData); | 267 | QCOMPARE(data, expectedPartData); | ||
267 | 268 | | |||
268 | // Make sure nothing is left behind in file_db_data | 269 | // Make sure nothing is left behind in file_db_data | ||
269 | // TODO: we have no way of knowing what is the last revision | 270 | // TODO: we have no way of knowing what is the last revision | ||
270 | for (int i = 0; i <= 100; ++i) { | 271 | for (int i = 0; i <= 100; ++i) { | ||
271 | const QByteArray fileName = QByteArray::number(part.id()) + "_r" + QByteArray::number(i); | 272 | const QByteArray fileName = QByteArray::number(part.id()) + "_r" + QByteArray::number(i); | ||
272 | const QString filePath = ExternalPartStorage::resolveAbsolutePath(fileName); | 273 | const QString filePath = ExternalPartStorage::resolveAbsolutePath(fileName); | ||
273 | QVERIFY2(!QFile::exists(filePath), qPrintable(filePath)); | 274 | QTRY_VERIFY2(!QFile::exists(filePath), qPrintable(filePath)); | ||
274 | } | 275 | } | ||
275 | } | 276 | } | ||
276 | } | 277 | } | ||
277 | 278 | | |||
278 | }; | 279 | }; | ||
279 | 280 | | |||
280 | AKTEST_FAKESERVER_MAIN(PartStreamerTest) | 281 | AKTEST_FAKESERVER_MAIN(PartStreamerTest) | ||
281 | 282 | | |||
282 | #include "partstreamertest.moc" | 283 | #include "partstreamertest.moc" |