qt5base-lts/tests/auto/cmake/test_import_plugins/main.cpp
Lucie Gérard 05fc3aef53 Use SPDX license identifiers
Replace the current license disclaimer in files by
a SPDX-License-Identifier.
Files that have to be modified by hand are modified.
License files are organized under LICENSES directory.

Task-number: QTBUG-67283
Change-Id: Id880c92784c40f3bbde861c0d93f58151c18b9f1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Jörg Bornemann <joerg.bornemann@qt.io>
2022-05-16 16:37:38 +02:00

55 lines
1.6 KiB
C++

// Copyright (C) 2018 Kitware, Inc.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
#include <QList>
#include <QPluginLoader>
#include <QSet>
#include <QString>
#include <cstddef>
#include <iostream>
extern QString expectedPlugins[];
extern std::size_t numExpectedPlugins;
int main(int argc, char **argv)
{
#ifdef QT_STATIC
QSet<QString> expectedPluginSet;
for (std::size_t i = 0; i < numExpectedPlugins; i++) {
expectedPluginSet.insert(expectedPlugins[i]);
}
QList<QStaticPlugin> plugins = QPluginLoader::staticPlugins();
QSet<QString> actualPluginSet;
for (QStaticPlugin plugin : plugins) {
actualPluginSet.insert(plugin.metaData()["className"].toString());
}
if (expectedPluginSet != actualPluginSet) {
std::cerr << "Loaded plugins do not match what was expected!" << std::endl
<< "Expected plugins:" << std::endl;
QList<QString> expectedPluginList = expectedPluginSet.values();
expectedPluginList.sort();
for (QString plugin : expectedPluginList) {
std::cerr << (actualPluginSet.contains(plugin) ? " " : "- ")
<< plugin.toStdString() << std::endl;
}
std::cerr << std::endl << "Actual plugins:" << std::endl;
QList<QString> actualPluginList = actualPluginSet.values();
actualPluginList.sort();
for (QString plugin : actualPluginList) {
std::cerr << (expectedPluginSet.contains(plugin) ? " " : "+ ")
<< plugin.toStdString() << std::endl;
}
return 1;
}
#endif
return 0;
}