Warning, file /frameworks/karchive/autotests/deprecatedtest.cpp was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 /* This file is part of the KDE project 0002 SPDX-FileCopyrightText: 2006, 2010 David Faure <faure@kde.org> 0003 SPDX-FileCopyrightText: 2012 Mario Bensi <mbensi@ipsquad.net> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #include <kzip.h> 0009 0010 #include <QTest> 0011 0012 static const char s_zipFileName[] = "deprecatedtest.zip"; 0013 0014 class DeprecatedTest : public QObject 0015 { 0016 Q_OBJECT 0017 0018 #if KARCHIVE_ENABLE_DEPRECATED_SINCE(5, 0) 0019 private Q_SLOTS: 0020 void testKArchiveWriteFile() 0021 { 0022 KZip zip(s_zipFileName); 0023 0024 QVERIFY(zip.open(QIODevice::WriteOnly)); 0025 0026 const QByteArray fileData("There could be a fire, if there is smoke."); 0027 const QString fileName = QStringLiteral("wisdom"); 0028 QVERIFY(zip.writeFile(fileName, "konqi", "dragons", fileData.constData(), fileData.size())); 0029 0030 QVERIFY(zip.close()); 0031 0032 QVERIFY(zip.open(QIODevice::ReadOnly)); 0033 0034 const KArchiveDirectory *dir = zip.directory(); 0035 QVERIFY(dir != nullptr); 0036 const QStringList listing = dir->entries(); 0037 QCOMPARE(listing.count(), 1); 0038 QCOMPARE(listing.at(0), fileName); 0039 const KArchiveEntry *entry = dir->entry(listing.at(0)); 0040 QCOMPARE(entry->permissions(), mode_t(0100644)); 0041 QVERIFY(!entry->isDirectory()); 0042 const KArchiveFile *fileEntry = static_cast<const KArchiveFile *>(entry); 0043 QCOMPARE(fileEntry->size(), fileData.size()); 0044 QCOMPARE(fileEntry->data(), fileData); 0045 } 0046 0047 /** 0048 * @see QTest::cleanupTestCase() 0049 */ 0050 void cleanupTestCase() 0051 { 0052 QFile::remove(s_zipFileName); 0053 } 0054 #endif 0055 }; 0056 0057 QTEST_MAIN(DeprecatedTest) 0058 0059 #include <deprecatedtest.moc>