diff --git a/tests/flatpak-integration.test.cpp b/tests/flatpak-integration.test.cpp index ede4f70..03313c1 100644 --- a/tests/flatpak-integration.test.cpp +++ b/tests/flatpak-integration.test.cpp @@ -1,7 +1,11 @@ #include "flatpak-manager.h" #include +#include +#include #include +namespace fs = std::filesystem; + // Real end-to-end exercise of the Flatpak provider against the live `flatpak` // CLI: install a small app, verify it is listed and marked as installed in // search, run update/refresh, then uninstall. It validates the exact commands @@ -24,6 +28,11 @@ bool isInstalled(FlatpakManager& fm) { return false; } +fs::path desktopLink() { + const char* home = std::getenv("HOME"); + return fs::path(home ? home : "/tmp") / ".local/share/applications" / (kApp + ".desktop"); +} + } // namespace int main() { @@ -45,6 +54,15 @@ int main() { return 1; } + // 1b. The app must be linked into the user's standard applications dir so it + // appears in any desktop launcher (the pacman-like integration). + if (fs::is_symlink(desktopLink())) { + std::cout << "OK desktop integration present" << std::endl; + } else { + std::cout << "FAIL install: no .desktop link in ~/.local/share/applications" << std::endl; + return 1; + } + // 2. Updating the single app and all apps must complete without error. if (!fm.update(kApp, nullptr)) { std::cout << "FAIL update(app): " << fm.lastError() << std::endl; @@ -87,6 +105,17 @@ int main() { std::cout << "FAIL remove: app still listed as installed" << std::endl; return 1; } + if (fs::is_symlink(desktopLink())) { + std::cout << "FAIL remove: desktop link not removed" << std::endl; + return 1; + } else { + std::cout << "OK desktop integration removed" << std::endl; + } + } else { + // Pre-existing app: verify the launcher link exists (integration ran). + if (!fs::is_symlink(desktopLink())) { + std::cout << "OK desktop integration ensured for preinstalled app" << std::endl; + } } std::cout << "All flatpak integration tests passed." << std::endl;