summaryrefslogtreecommitdiffstats
path: root/tests/auto/installer/shared/verifyinstaller.h
diff options
context:
space:
mode:
Diffstat (limited to 'tests/auto/installer/shared/verifyinstaller.h')
-rw-r--r--tests/auto/installer/shared/verifyinstaller.h33
1 files changed, 28 insertions, 5 deletions
diff --git a/tests/auto/installer/shared/verifyinstaller.h b/tests/auto/installer/shared/verifyinstaller.h
index 7cd2af05b..e19d3fa0a 100644
--- a/tests/auto/installer/shared/verifyinstaller.h
+++ b/tests/auto/installer/shared/verifyinstaller.h
@@ -1,6 +1,6 @@
/**************************************************************************
**
-** Copyright (C) 2020 The Qt Company Ltd.
+** Copyright (C) 2023 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
**
** This file is part of the Qt Installer Framework.
@@ -29,6 +29,8 @@
#ifndef VERIFYINSTALLER_H
#define VERIFYINSTALLER_H
+#include <packagemanagercore.h>
+
#include <QString>
#include <QStringList>
#include <QCryptographicHash>
@@ -36,21 +38,25 @@
#include <QDir>
#include <QtTest/QTest>
+#include <iostream>
+#include <sstream>
+
struct VerifyInstaller
{
static void verifyInstallerResources(const QString &installDir, const QString &componentName, const QString &fileName)
{
QDir dir(installDir + QDir::separator() + "installerResources" + QDir::separator() + componentName);
- QVERIFY(dir.exists());
+ QVERIFY2(dir.exists(), qPrintable(QLatin1String("Directory: \"%1\" does not exist").arg(dir.absolutePath())));
QFileInfo fileInfo;
fileInfo.setFile(dir, fileName);
- QVERIFY(fileInfo.exists());
+ QVERIFY2(fileInfo.exists(), qPrintable(QLatin1String("File: \"%1\" does not exist for \"%2\".")
+ .arg(fileName).arg(componentName)));
}
static void verifyInstallerResourcesDeletion(const QString &installDir, const QString &componentName)
{
QDir dir(installDir + QDir::separator() + "installerResources" + QDir::separator() + componentName);
- QVERIFY(!dir.exists());
+ QVERIFY2(!dir.exists(), qPrintable(QLatin1String("Directory: \"%1\" is not deleted.").arg(dir.absolutePath())));
}
static void verifyInstallerResourceFileDeletion(const QString &installDir, const QString &componentName, const QString &fileName)
@@ -58,7 +64,8 @@ struct VerifyInstaller
QDir dir(installDir + QDir::separator() + "installerResources" + QDir::separator() + componentName);
QFileInfo fileInfo;
fileInfo.setFile(dir, fileName);
- QVERIFY(!fileInfo.exists());
+ QVERIFY2(!fileInfo.exists(), qPrintable(QLatin1String("File: \"%1\" still exists for \"%2\".")
+ .arg(fileName).arg(componentName)));
}
static void verifyFileExistence(const QString &installDir, const QStringList &fileList)
@@ -112,5 +119,21 @@ struct VerifyInstaller
}
}
}
+
+ template <typename Func, typename... Args>
+ static void verifyListPackagesMessage(QInstaller::PackageManagerCore *core, const QString &message,
+ Func func, Args... args)
+ {
+ std::ostringstream stream;
+ std::streambuf *buf = std::cout.rdbuf();
+ std::cout.rdbuf(stream.rdbuf());
+
+ (core->*func)(std::forward<Args>(args)...);
+
+ std::cout.rdbuf(buf);
+ QVERIFY(stream && stream.tellp() == message.size());
+ for (const QString &line : message.split(QLatin1String("\n")))
+ QVERIFY(stream.str().find(line.toStdString()) != std::string::npos);
+ }
};
#endif