Files
logos-package-manager-module/tests/package_manager_events_test.cpp
Dario LipicarandClaude Opus 4.8 cad6bab044 feat: fresh-install gate + thread dep changes through the gated flow (#57)
* feat: add fresh-install gate + thread dep changes through gated flow

Adds a confirmation gate for fresh installs (requestInstall / confirmInstall /
cancelInstall + beforeInstall / installApproved / installCancelled events),
mirroring the existing uninstall/upgrade gate but with no in-module uninstall
step — confirmInstall simply emits installApproved so the initiator runs its
own download+install chain.

Also extends requestUpgrade with an opaque `depChanges` JSON argument that is
echoed into the beforeUpgrade / beforeInstall payload, so a host confirmation
dialog can list the transitive dependency changes an operation will apply. The
module never interprets it (malformed/empty -> empty array).

This lets the host (basecamp) own a single confirmation dialog for install,
upgrade, and downgrade — replacing the double-dialog where PMUI and basecamp
both confirmed.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* chore: address review nits — confirmInstall single critical section + depChanges doc

- confirmInstall now validates, captures the echo fields, and clears the gate
  in ONE critical section instead of two, so a concurrent cancel/reset/
  ack-timeout can't swap the pending action out between the check and the
  capture (which would emit installApproved with an empty/wrong payload).
  No behavior change under the current single-dispatch model; hardens against
  a future concurrency:multi flip.
- Fix requestUpgrade/requestInstall depChanges doc: the module DOES parse the
  JSON (to re-embed it as an array via attachDepChanges) but never interprets
  or acts on its contents.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-16 23:12:23 -03:00

28 lines
2.2 KiB
C++

// Qt-free test bodies for PackageManagerImpl's `logos_events:` methods.
//
// Production bodies are codegen-emitted in package_manager_events.cpp (Qt
// marshaling); the unit/integration tests don't link that. These forwarders
// route each event's single string payload to logos_test's active capture
// (logos_test::EventCapture / ScopedEventSink — see <logos_test.h>). Linked
// into both test executables so package_manager_impl.cpp's emit calls resolve.
#include <logos_test.h>
#include "package_manager_impl.h"
using logos_test::recordEvent;
void PackageManagerImpl::corePluginFileInstalled(const std::string& path) { recordEvent("corePluginFileInstalled", path); }
void PackageManagerImpl::uiPluginFileInstalled(const std::string& path) { recordEvent("uiPluginFileInstalled", path); }
void PackageManagerImpl::corePluginUninstalled(const std::string& name) { recordEvent("corePluginUninstalled", name); }
void PackageManagerImpl::uiPluginUninstalled(const std::string& name) { recordEvent("uiPluginUninstalled", name); }
void PackageManagerImpl::beforeUninstall(const std::string& payload) { recordEvent("beforeUninstall", payload); }
void PackageManagerImpl::beforeUpgrade(const std::string& payload) { recordEvent("beforeUpgrade", payload); }
void PackageManagerImpl::beforeInstall(const std::string& payload) { recordEvent("beforeInstall", payload); }
void PackageManagerImpl::beforeMultiUninstall(const std::string& payload) { recordEvent("beforeMultiUninstall", payload); }
void PackageManagerImpl::uninstallCancelled(const std::string& payload) { recordEvent("uninstallCancelled", payload); }
void PackageManagerImpl::upgradeCancelled(const std::string& payload) { recordEvent("upgradeCancelled", payload); }
void PackageManagerImpl::installCancelled(const std::string& payload) { recordEvent("installCancelled", payload); }
void PackageManagerImpl::multiUninstallCancelled(const std::string& payload) { recordEvent("multiUninstallCancelled", payload); }
void PackageManagerImpl::upgradeUninstallDone(const std::string& payload) { recordEvent("upgradeUninstallDone", payload); }
void PackageManagerImpl::installApproved(const std::string& payload) { recordEvent("installApproved", payload); }