mirror of
https://github.com/OrcaSlicer/OrcaSlicer.git
synced 2026-06-10 14:02:47 +00:00
feat(automation): add open_files to backend interface + kErrLoadFailed (1007)
This commit is contained in:
@@ -95,6 +95,12 @@ public:
|
||||
// Screenshot. target == nullptr => main frame. Captured from the on-screen
|
||||
// composited framebuffer, so it includes the GL viewport and ImGui overlays.
|
||||
virtual PngImage screenshot_window(const UiNode* target) = 0;
|
||||
|
||||
// Load one or more files (absolute paths) into the running instance on the GUI
|
||||
// thread. Returns the number of objects added to the scene (load_files(...).size()).
|
||||
// Throws AutomationError(kErrLoadFailed) when nothing loads. Header stays wx-free:
|
||||
// the concrete LoadStrategy is chosen inside WxUiBackend, not exposed here.
|
||||
virtual int open_files(const std::vector<std::string>& paths) = 0;
|
||||
};
|
||||
|
||||
}}} // namespace Slic3r::GUI::Automation
|
||||
|
||||
@@ -17,6 +17,7 @@ constexpr int kErrWaitTimeout = 1003;
|
||||
constexpr int kErrGuiBusy = 1004; // GUI thread timeout
|
||||
constexpr int kErrScreenshotFail = 1005;
|
||||
constexpr int kErrDisabled = 1006;
|
||||
constexpr int kErrLoadFailed = 1007; // file.open: load_files returned empty / threw
|
||||
|
||||
constexpr const char* kProtocolVersion = "2.0";
|
||||
constexpr const char* kAutomationVersion = "1.0.0";
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#pragma once
|
||||
#include "slic3r/GUI/Automation/IUiBackend.hpp"
|
||||
#include "slic3r/GUI/Automation/JsonRpcDispatcher.hpp" // kErrLoadFailed
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
@@ -18,12 +19,15 @@ public:
|
||||
std::vector<std::string> typed_text;
|
||||
std::vector<std::vector<KeyChord>> sent_keys;
|
||||
int screenshot_window_count = 0;
|
||||
std::vector<std::vector<std::string>> opened_paths; // paths of each open_files()
|
||||
|
||||
// Canned outputs (set by tests).
|
||||
UiNode tree; // default tree for dump_tree
|
||||
AppState state;
|
||||
PngImage canned_png{ {0x89,0x50,0x4E,0x47}, 4, 4 }; // fake "PNG" bytes
|
||||
bool click_result = true;
|
||||
int open_return_count = 0; // value open_files() returns
|
||||
bool open_should_fail = false; // when true, open_files() throws kErrLoadFailed
|
||||
|
||||
// Optional: per-call tree provider (overrides `tree` when set).
|
||||
std::function<UiNode(int /*call_index*/)> tree_provider;
|
||||
@@ -49,6 +53,12 @@ public:
|
||||
PngImage screenshot_window(const UiNode*) override {
|
||||
++screenshot_window_count; return canned_png;
|
||||
}
|
||||
int open_files(const std::vector<std::string>& paths) override {
|
||||
opened_paths.push_back(paths);
|
||||
if (open_should_fail)
|
||||
throw AutomationError(kErrLoadFailed, "mock load failed");
|
||||
return open_return_count;
|
||||
}
|
||||
};
|
||||
|
||||
}}} // namespace
|
||||
|
||||
Reference in New Issue
Block a user