Rewires the flatpak unit, integration and plugin-manager tests to compile against plugins/flatpak-provider, and updates plugin-manager.test to treat flatpak as a runtime-loaded plugin rather than a registered built-in. Generated with Codebuff 🤖 Co-Authored-By: Codebuff <noreply@codebuff.com>
77 lines
2.9 KiB
C++
77 lines
2.9 KiB
C++
#include "plugin-manager.h"
|
|
#include "pacman-manager.h"
|
|
#include "flatpak-manager.h"
|
|
#include <QCoreApplication>
|
|
#include <cassert>
|
|
#include <iostream>
|
|
|
|
// Exercises PluginManager end-to-end: built-in registration plus runtime
|
|
// discovery of the example plugin (built into build/plugins by CMake when
|
|
// FWS_BUILD_EXAMPLE_PLUGIN=ON).
|
|
int main(int argc, char* argv[]) {
|
|
QCoreApplication app(argc, argv);
|
|
app.setOrganizationName("Freebuff");
|
|
app.setApplicationName("PacManager");
|
|
|
|
PluginManager pm;
|
|
pm.registerBuiltin({"pacman", "Pacman", "1.0.0", "Natif Arch Linux", "FWS"},
|
|
new PacmanManager());
|
|
// Flatpak now ships as an external plugin (dropped next to the test binary
|
|
// by CMake, like the sample plugin) rather than a compiled-in provider.
|
|
pm.discoverExternal();
|
|
|
|
// pacman built-in + the flatpak and sample plugins dropped next to the
|
|
// test binary.
|
|
assert(pm.providers().size() == 3);
|
|
|
|
// Install hints are exposed per provider; the sample plugin omits its
|
|
// optional hint symbol (must read back empty), while the flatpak plugin
|
|
// declares the OS package backing its tool.
|
|
const auto& providers = pm.providers();
|
|
for (const auto& entry : providers) {
|
|
if (entry.info.id == "flatpak") {
|
|
assert(!entry.info.builtin);
|
|
assert(entry.info.installHint == "flatpak");
|
|
}
|
|
if (entry.info.id == "sample") assert(entry.info.installHint.empty());
|
|
}
|
|
assert(pm.findAvailable("flatpak") != nullptr);
|
|
|
|
// External plugin metadata is exposed through the C ABI.
|
|
const auto* sample = pm.findAvailable("sample");
|
|
assert(sample != nullptr);
|
|
assert(sample->info.name == "Sample Provider");
|
|
assert(sample->info.version == "0.1.0");
|
|
assert(sample->info.author == "FWS");
|
|
assert(!sample->info.builtin);
|
|
assert(sample->manager != nullptr);
|
|
assert(sample->manager->getName() == "sample");
|
|
assert(sample->manager->isAvailable());
|
|
|
|
// Manager lookup works by id.
|
|
IPackageManager* pacman = pm.managerFor("pacman");
|
|
assert(pacman != nullptr);
|
|
assert(pacman->getName() == "pacman");
|
|
|
|
// Enable/disable is persisted and filters the available list.
|
|
assert(pm.isEnabled("sample"));
|
|
pm.setEnabled("sample", false);
|
|
assert(!pm.isEnabled("sample"));
|
|
assert(pm.findAvailable("sample") == nullptr);
|
|
pm.setEnabled("sample", true);
|
|
assert(pm.findAvailable("sample") != nullptr);
|
|
|
|
// Reload keeps built-ins (same instance) and rescans external plugins.
|
|
IPackageManager* pacmanBefore = pacman;
|
|
pm.reload();
|
|
assert(pm.managerFor("pacman") == pacmanBefore);
|
|
assert(pm.findAvailable("sample") != nullptr);
|
|
|
|
// refreshAvailability re-evaluates the presence of every tool.
|
|
pm.refreshAvailability();
|
|
assert(pm.findAvailable("pacman") != nullptr);
|
|
|
|
std::cout << "All plugin-manager tests passed." << std::endl;
|
|
return 0;
|
|
}
|