1553
TestDownload::testFileRemoveAfterSuccessfulProcess() {
1554
// assert that the file is indeed removed
1555
QVariantMap metadata;
1556
QStringList command;
1557
command << "grep" << "$file" << "-Rn";
1558
metadata["post-download-command"] = command;
1560
_processFactory->record();
1561
_reqFactory->record();
1562
SingleDownload* download = new SingleDownload(_id, _path, _isConfined,
1563
_rootPath, _url, metadata, _headers,
1564
QSharedPointer<SystemNetworkInfo>(_networkInfo),
1565
QSharedPointer<RequestFactory>(_reqFactory),
1566
QSharedPointer<ProcessFactory>(_processFactory));
1568
// write something in the expected file
1569
QString fileName = download->filePath();
1570
QFile* file = new QFile(fileName);
1571
file->open(QIODevice::ReadWrite | QFile::Append);
1572
file->write("my data goes here");
1575
download->start(); // change state
1576
download->startDownload();
1578
// we need to set the data before we pause!!!
1579
QList<MethodData> calledMethods = _reqFactory->calledMethods();
1580
QCOMPARE(1, calledMethods.count());
1581
FakeNetworkReply* reply = reinterpret_cast<FakeNetworkReply*>(
1582
calledMethods[0].params().outParams()[0]);
1584
// makes the process to be executed
1585
reply->emitFinished();
1587
calledMethods = _processFactory->calledMethods();
1588
QCOMPARE(1, calledMethods.count());
1589
FakeProcess* process = reinterpret_cast<FakeProcess*>(
1590
calledMethods[0].params().outParams()[0]);
1592
// emit the finished signal with a result > 0 and ensure error is emitted
1593
process->emitFinished(0, QProcess::NormalExit);
1594
// asser that the file does not longer exist in the system
1595
QVERIFY(!QFile::exists(fileName));
1553
1599
TestDownload::testSetRawHeaderAcceptEncoding_data() {
1554
1600
QTest::addColumn<QMap<QString, QString> >("headers");