swift
Loading...
Searching...
No Matches
testcompress.cpp
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (C) 2018 swift Project Community / Contributors
2// SPDX-License-Identifier: GPL-3.0-or-later OR LicenseRef-swift-pilot-client-1
3
5
10
11#include <QFileInfo>
12#include <QObject>
13#include <QTemporaryDir>
14#include <QTest>
15
16#include "test.h"
17
18#include "config/buildconfig.h"
19#include "misc/compressutils.h"
20#include "misc/directoryutils.h"
21#include "misc/fileutils.h"
23
24using namespace swift::misc;
25using namespace swift::config;
26
27namespace MiscTest
28{
30 class CTestCompress : public QObject
31 {
33
34 public:
36 explicit CTestCompress(QObject *parent = nullptr) : QObject(parent) {}
37
39 ~CTestCompress() override = default;
40
41 private slots:
43 void uncompressFile();
44 };
45
46 void CTestCompress::uncompressFile()
47 {
48 QTemporaryDir tempDir;
49 tempDir.setAutoRemove(true);
50 QVERIFY2(tempDir.isValid(), "Invalid directory");
51
52 const QString td = tempDir.path();
54 const QString unCompressedFile(CFileUtils::appendFilePaths(td, "1.txt"));
55 const bool c = CCompressUtils::zipUncompress(compressedFile, td);
56
57 QVERIFY2(c, "Uncompressing failed");
58
59 const QFileInfo check(unCompressedFile);
60 QVERIFY2(check.exists(), "Uncompressed file does not exist");
61 QVERIFY2(check.isReadable(), "Not readable");
62
63 qDebug() << "Uncompressed" << compressedFile << "to" << unCompressedFile << "with size" << check.size();
64 }
65} // namespace MiscTest
66
69
70#include "testcompress.moc"
71
Testing process tools.
~CTestCompress()=default
Destructor.
CTestCompress(QObject *parent=nullptr)
Constructor.
static bool zipUncompress(const QString &file, const QString &directory, QStringList *stdOutAndError=nullptr)
Unzip file.
static QString appendFilePaths(const QString &path1, const QString &path2)
Append file paths.
static const QString & shareTestDirectory()
The test data directory.
Free functions in swift::misc.
QObject(QObject *parent)
Q_OBJECTQ_OBJECT
QObject * parent() const const
bool isValid() const const
QString path() const const
void setAutoRemove(bool b)
#define SWIFTTEST_MAIN(TestObject)
Implements a main() function that executes all tests in TestObject including instantiating a QCoreApp...
Definition test.h:57