| 130 | } |
| 131 | |
| 132 | void TestJlCompress::compressFileOptions() |
| 133 | { |
| 134 | QFETCH(QString, zipName); |
| 135 | QFETCH(QString, fileName); |
| 136 | QFETCH(QDateTime, dateTime); |
| 137 | QFETCH(JlCompress::Options::CompressionStrategy, strategy); |
| 138 | QFETCH(QString, sha256sum_unix); |
| 139 | QFETCH(QString, sha256sum_win); |
| 140 | QDir curDir; |
| 141 | if (curDir.exists(zipName)) { |
| 142 | if (!curDir.remove(zipName)) |
| 143 | QFAIL("Can't remove zip file"); |
| 144 | } |
| 145 | if (!createTestFiles(QStringList() << fileName)) { |
| 146 | QFAIL("Can't create test file"); |
| 147 | } |
| 148 | |
| 149 | const JlCompress::Options options(dateTime, strategy); |
| 150 | QVERIFY(JlCompress::compressFile(zipName, "tmp/" + fileName, options)); |
| 151 | // get the file list and check it |
| 152 | QStringList fileList = JlCompress::getFileList(zipName); |
| 153 | QCOMPARE(fileList.count(), 1); |
| 154 | QVERIFY(fileList[0] == fileName); |
| 155 | // now test the QIODevice* overload of getFileList() |
| 156 | QFile zipFile(zipName); |
| 157 | QVERIFY(zipFile.open(QIODevice::ReadOnly)); |
| 158 | fileList = JlCompress::getFileList(zipName); |
| 159 | QCOMPARE(fileList.count(), 1); |
| 160 | QVERIFY(fileList[0] == fileName); |
| 161 | // Hash is computed on the resulting file externally, then hardcoded in the test data |
| 162 | // This should help detecting any library breakage since we compare against a well-known stable result |
| 163 | QString hash = QCryptographicHash::hash(zipFile.readAll(), QCryptographicHash::Sha256).toHex(); |
| 164 | #ifdef Q_OS_WIN |
| 165 | if (!sha256sum_win.isEmpty()) QCOMPARE(hash, sha256sum_win); |
| 166 | #else |
| 167 | if (!sha256sum_unix.isEmpty()) QCOMPARE(hash, sha256sum_unix); |
| 168 | #endif |
| 169 | zipFile.close(); |
| 170 | removeTestFiles(QStringList() << fileName); |
| 171 | curDir.remove(zipName); |
| 172 | } |
| 173 | |
| 174 | void TestJlCompress::compressFiles_data() |
| 175 | { |
nothing calls this directly
no test coverage detected