| 59 | } |
| 60 | |
| 61 | void TestQuaZip::getFileList() |
| 62 | { |
| 63 | QFETCH(QString, zipName); |
| 64 | QFETCH(QStringList, fileNames); |
| 65 | fileNames.sort(); |
| 66 | QDir curDir; |
| 67 | if (curDir.exists(zipName)) { |
| 68 | if (!curDir.remove(zipName)) |
| 69 | QFAIL("Can't remove zip file"); |
| 70 | } |
| 71 | if (!createTestFiles(fileNames)) { |
| 72 | QFAIL("Can't create test file"); |
| 73 | } |
| 74 | if (!createTestArchive(zipName, fileNames)) { |
| 75 | QFAIL("Can't create test archive"); |
| 76 | } |
| 77 | QuaZip testZip(zipName); |
| 78 | QVERIFY(testZip.open(QuaZip::mdUnzip)); |
| 79 | QVERIFY(testZip.goToFirstFile()); |
| 80 | QString firstFile = testZip.getCurrentFileName(); |
| 81 | QStringList fileList = testZip.getFileNameList(); |
| 82 | fileList.sort(); |
| 83 | QCOMPARE(fileList, fileNames); |
| 84 | QHash<QString, QFileInfo> srcInfo; |
| 85 | foreach (QString fileName, fileNames) { |
| 86 | srcInfo[fileName] = QFileInfo("tmp/" + fileName); |
| 87 | } |
| 88 | QList<QuaZipFileInfo> destList = testZip.getFileInfoList(); |
| 89 | QCOMPARE(destList.size(), srcInfo.size()); |
| 90 | for (const auto& dest : destList) { |
| 91 | QCOMPARE(static_cast<qint64>(dest.uncompressedSize), |
| 92 | srcInfo[dest.name].size()); |
| 93 | } |
| 94 | // Now test zip64 |
| 95 | QList<QuaZipFileInfo64> destList64 = testZip.getFileInfoList64(); |
| 96 | QCOMPARE(destList64.size(), srcInfo.size()); |
| 97 | for (const auto& dest : destList64) { |
| 98 | QCOMPARE(static_cast<qint64>(dest.uncompressedSize), |
| 99 | srcInfo[dest.name].size()); |
| 100 | } |
| 101 | // test that we didn't mess up the current file |
| 102 | QCOMPARE(testZip.getCurrentFileName(), firstFile); |
| 103 | testZip.close(); |
| 104 | // clean up |
| 105 | removeTestFiles(fileNames); |
| 106 | curDir.remove(zipName); |
| 107 | } |
| 108 | |
| 109 | void TestQuaZip::add_data() |
| 110 | { |
nothing calls this directly
no test coverage detected