diff options
Diffstat (limited to 'tests/auto/installer/shared/verifyinstaller.h')
-rw-r--r-- | tests/auto/installer/shared/verifyinstaller.h | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/tests/auto/installer/shared/verifyinstaller.h b/tests/auto/installer/shared/verifyinstaller.h index 4d70c577b..e19d3fa0a 100644 --- a/tests/auto/installer/shared/verifyinstaller.h +++ b/tests/auto/installer/shared/verifyinstaller.h @@ -1,6 +1,6 @@ /************************************************************************** ** -** Copyright (C) 2022 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,6 +38,9 @@ #include <QDir> #include <QtTest/QTest> +#include <iostream> +#include <sstream> + struct VerifyInstaller { static void verifyInstallerResources(const QString &installDir, const QString &componentName, const QString &fileName) @@ -114,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 |