mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-07-23 02:42:08 +00:00
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.
This commit is contained in:
35
tests/slic3rutils/test_action_source.cpp
Normal file
35
tests/slic3rutils/test_action_source.cpp
Normal file
@@ -0,0 +1,35 @@
|
||||
#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);
|
||||
}
|
||||
Reference in New Issue
Block a user