summaryrefslogtreecommitdiffstats
path: root/tests/auto/installer
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/installer')
-rw-r--r--tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp3
-rw-r--r--tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp92
2 files changed, 38 insertions, 57 deletions
diff --git a/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp b/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp
index b87cea791..f4188a979 100644
--- a/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp
+++ b/tests/auto/installer/extractarchiveoperationtest/tst_extractarchiveoperationtest.cpp
@@ -86,7 +86,8 @@ private slots:
QVERIFY(op.undoOperation());
QCOMPARE(UpdateOperation::Error(op.error()), UpdateOperation::UserDefinedError);
- QCOMPARE(op.errorString(), QString("Error while extracting ':///data/invalid.7z': Could not open archive"));
+ QCOMPARE(op.errorString(), QString("Error while extracting ':///data/invalid.7z': Could "
+ "not open archive ':///data/invalid.7z'."));
}
};
diff --git a/tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp b/tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp
index 815afb0a2..5a523c3b2 100644
--- a/tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp
+++ b/tests/auto/installer/lib7zfacade/tst_lib7zfacade.cpp
@@ -32,8 +32,7 @@
**
**************************************************************************/
-#include "init.h"
-#include "lib7z_facade.h"
+#include <lib7z_facade.h>
#include <QDir>
#include <QObject>
@@ -47,7 +46,7 @@ class tst_lib7zfacade : public QObject
private slots:
void initTestCase()
{
- QInstaller::init();
+ Lib7z::initSevenZ();
m_file.path = "valid";
m_file.permissions = 0;
@@ -63,24 +62,26 @@ private slots:
QCOMPARE(Lib7z::isSupportedArchive(":///data/valid.7z"), true);
QCOMPARE(Lib7z::isSupportedArchive(":///data/invalid.7z"), false);
- {
+ try {
QFile file(":///data/valid.7z");
QVERIFY(file.open(QIODevice::ReadOnly));
QCOMPARE(Lib7z::isSupportedArchive(&file), true);
+ } catch (...) {
+ QFAIL("Unexpected error during Lib7z::isSupportedArchive.");
}
- {
+ try {
QFile file(":///data/invalid.7z");
QVERIFY(file.open(QIODevice::ReadOnly));
QCOMPARE(Lib7z::isSupportedArchive(&file), false);
+ } catch (...) {
+ QFAIL("Unexpected error during Lib7z::isSupportedArchive.");
}
}
void testListArchive()
{
- // TODO: this should work without scope, there's a bug in Lib7z::OpenArchiveInfo
- // caused by the fact that we keep a pointer to the device, not the devices target
- {
+ try {
QFile file(":///data/valid.7z");
QVERIFY(file.open(QIODevice::ReadOnly));
@@ -90,82 +91,61 @@ private slots:
QSKIP("This test requires the time handling to be repaired first.");
#endif
QCOMPARE(files.first(), m_file);
+ } catch (...) {
+ QFAIL("Unexpected error during list archive.");
}
- {
- try {
- QFile file(":///data/invalid.7z");
- QVERIFY(file.open(QIODevice::ReadOnly));
- QVector<Lib7z::File> files = Lib7z::listArchive(&file);
- } catch (const Lib7z::SevenZipException& e) {
- QCOMPARE(e.message(), QString("Could not open archive"));
- } catch (...) {
- QFAIL("Unexpected error during list archive!");
- }
- }
- }
-
- void testCreateArchive()
- {
- QTemporaryFile target;
- QVERIFY(target.open());
-
try {
- // TODO: we do not get any information about success
- Lib7z::createArchive(&target, QStringList() << ":///data/invalid.7z");
+ QFile file(":///data/invalid.7z");
+ QVERIFY(file.open(QIODevice::ReadOnly));
+ QVector<Lib7z::File> files = Lib7z::listArchive(&file);
} catch (const Lib7z::SevenZipException& e) {
- QFAIL(e.message().toUtf8());
+ QCOMPARE(e.message(), QString("Could not open archive ':///data/invalid.7z'."));
} catch (...) {
- QFAIL("Unexpected error during create archive!");
+ QFAIL("Unexpected error during list archive.");
}
}
- void testExtractArchive()
+ void testCreateArchive()
{
- QFile source(":///data/valid.7z");
- QVERIFY(source.open(QIODevice::ReadOnly));
-
try {
- // TODO: we do not get any information about success
- Lib7z::extractArchive(&source, QDir::tempPath());
+ const QString path = tempSourceFile("Source File 1.");
+ const QString path2 = tempSourceFile("Source File 2.");
+
+ QTemporaryFile target;
+ QVERIFY(target.open());
+ Lib7z::createArchive(&target, QStringList() << path << path2);
+ QCOMPARE(Lib7z::listArchive(&target).count(), 2);
} catch (const Lib7z::SevenZipException& e) {
QFAIL(e.message().toUtf8());
} catch (...) {
- QFAIL("Unexpected error during extract archive!");
+ QFAIL("Unexpected error during create archive.");
}
}
- void testExtractFileFromArchive()
+ void testExtractArchive()
{
QFile source(":///data/valid.7z");
QVERIFY(source.open(QIODevice::ReadOnly));
- QTemporaryFile target;
- QVERIFY(target.open());
-
try {
- // TODO: we do not get any information about success
- Lib7z::extractFileFromArchive(&source, m_file, &target);
+ Lib7z::extractArchive(&source, QDir::tempPath());
+ QCOMPARE(QFile::exists(QDir::tempPath() + QString("/valid")), true);
} catch (const Lib7z::SevenZipException& e) {
QFAIL(e.message().toUtf8());
} catch (...) {
- QFAIL("Unexpected error during extract file from archive!");
+ QFAIL("Unexpected error during extract archive.");
}
}
- void testExtractFileFromArchive2()
+private:
+ QString tempSourceFile(const QByteArray &data)
{
- QFile source(":///data/valid.7z");
- QVERIFY(source.open(QIODevice::ReadOnly));
-
- try {
- // TODO: we do not get any information about success
- Lib7z::extractFileFromArchive(&source, m_file, QDir::tempPath());
- } catch (const Lib7z::SevenZipException& e) {
- QFAIL(e.message().toUtf8());
- } catch (...) {
- QFAIL("Unexpected error during extract file from archive!");
- }
+ QTemporaryFile source;
+ source.open();
+ source.write(data);
+ source.setAutoRemove(false);
+ return source.fileName();
}
private: