Files
OrcaSlicer/tests/slic3rutils/test_action_source.cpp
Andrew c29ffdfc1a Extract script actions into an action source
Move plugin capability enumeration, loader
subscriptions, and action construction into
ScriptActionSource. Keep ActionRegistry focused
on generic action state, dispatch, and snapshots.

Use source rather than package for generic origin
metadata so future non-plugin providers share the
same interface. Action IDs and persisted
configuration remain unchanged.

Subscribe before initial enumeration so plugin
events cannot be missed between the snapshot and
callback registration. Add a focused test for
source startup.
2026-07-13 14:28:05 +08:00

36 lines
743 B
C++

#include <catch2/catch_test_macros.hpp>
#include "slic3r/GUI/ActionRegistry.hpp"
#include "slic3r/GUI/IActionSource.hpp"
#include <memory>
using Slic3r::GUI::ActionRegistry;
using Slic3r::GUI::IActionSource;
namespace {
class RecordingActionSource final : public IActionSource
{
public:
explicit RecordingActionSource(bool& started) : m_started(started) {}
void start(ActionRegistry&) override { m_started = true; }
private:
bool& m_started;
};
} // namespace
TEST_CASE("ActionRegistry starts registered action sources", "[speeddial][actions]")
{
bool started = false;
ActionRegistry registry;
registry.add_source(std::make_unique<RecordingActionSource>(started));
registry.init();
CHECK(started);
}