Check every area of the MCP sweep with Python tests that read each step back

The sweep's objects, presets, filaments, settings, project files, slicing, gizmos and GUI tools are tested by Python
tests that compare the app's state after every step with the values their entries write out, in place of the
replays, and the existing tests' checks that could not fail now can. The calls these tests found wrong now behave
as described: moving one instance no longer sinks the others, a toolpath export writes the layers shown, an
auto-answered dialog no longer reports its call blocked, and a web dialog that has just opened takes requests.
This commit is contained in:
SoftFever committed 2026-11-19 13:49:20 +08:00
1 parent f80433cff0
commit 6cd2ce1a2e
112 files changed
+11599 -6079

No files matched your search

+39 -36
View File
@@ -301,7 +301,9 @@ tests that need a call to outlive its budget without waiting 45 s for it.
**blocked_by_dialog.** A handler that opens a modal blocks in its nested loop, so every 1.5 s the
request thread posts a probe closure, which runs inside a wx dialog's loop and returns the
`ModalTracker` snapshot as JSON; no `wxDialog*` crosses threads. With a modal open, the reply is
`{status: "blocked_by_dialog", job, dialogs}`. Its note says how to answer the topmost dialog:
`{status: "blocked_by_dialog", job, dialogs}`, once a second probe, posted at once, finds the same dialog on top:
an auto-answer rule presses a wx dialog's button from a closure queued as the dialog opens, which a probe posted
before the dialog opened runs ahead of, and the second probe runs after it. Its note says how to answer the topmost dialog:
`dialog_answer` for a wx dialog or a native message box whose buttons are listed, a person for any
other dialog marked `native: true` (a picker, or any native dialog on macOS), which `dialog_answer`
can't press.
@@ -3056,7 +3058,9 @@ shown, left out when none is shown.
`ModalTracker`, a `wxModalDialogHook`, sees every `ShowModal()`, native dialogs included, and
publishes the snapshot `[{title, message, class, native, buttons}]`, which other threads read. Read on
the UI thread, as `app_state`, the `blocked_by_dialog` probe, the guards' refusals and the input tools'
`dialogs` read it, the snapshot describes the open dialogs again first. So it shows a dialog as it is
`dialogs` read it, the snapshot describes the open dialogs again first. The guards themselves only ask whether a
dialog is open: describing one reads every control, and done for every closure the UI thread runs, it would keep
a dialog's own events waiting while many calls queue. So it shows a dialog as it is
now: text the dialog filled in once it showed (a printer's name, a list from a scan), a field typed in,
a page switched. Should describing fail, the last description stands. Only a native dialog that holds
the UI thread (macOS) leaves readers with the description published before it; its content does not
@@ -3261,7 +3265,9 @@ port, and a page may close its dialog, destroying the web view, at any time. `Pa
on the UI thread and wait for them on the job thread, a destruction watcher ending the wait for a
web view that goes. Job and request threads hold a web view as a `WebHandle`, a number only the UI
thread maps back to it, never as a `wxWeakRef`: making or dropping one edits the window's list of
refs, which the UI thread edits at the same time.
refs, which the UI thread edits at the same time. A web view whose native view is not made yet, which WebView2
makes a moment after its window opens, holds the call's request and sends it once the view is there, trying every
100 ms for up to 10 s.
What a page lists, after Playwright's accessibility snapshot: each element with a role as a kind
(button, link, text, checkbox, radio, choice with its options, slider, spin, tab, heading, row,
@@ -4633,26 +4639,25 @@ the app on Linux on the XWayland of a private headless compositor (KWin, else mu
tested yet), which gives it the GPU's OpenGL and a window manager, or, on a machine without a desktop,
on a private Xvfb display (with `-noreset`, and the pointer parked in a corner so no tooltip lands in
a screenshot); on macOS and Windows it opens the app on the desktop. It runs
`tools/mcp/smoke_test.json`, which `--run` also runs headless. `tools/mcp/tests/gizmos.json`
checks every gizmo through the GUI tools,
`tools/mcp/tests/multicolor.json` object and part filaments and the project's settings, `tools/mcp/tests/presets.json` saving,
`tools/mcp/smoke_test.json`, which `--run` also runs headless. `tools/mcp/test_gizmos.py`
checks every gizmo through the GUI tools, with auto-answers that run a button's handler and canvas targets on
negative parts and from below the bed, `tools/mcp/test_filaments.py` a filament preset assigned to a slot by every
route, the Auto-flush preference, object and part filaments and the project's settings,
`tools/mcp/test_presets.py` selecting presets by the names their selectors show, hidden ones included, saving,
reading and comparing presets, explaining settings, per-variant entries, `changed`, reverting keys, answering the
unsaved-changes prompts of a preset switch and a new project, deleting presets, exporting and importing
presets with a path, and reading a preference changed in the Preferences dialog,
unsaved-changes prompts of a preset switch and a new project, deleting presets, exporting and importing presets
with a path, and reading a preference changed in the Preferences dialog,
`tools/mcp/test_plates.py` plates added, duplicated, named, locked, selected and deleted, what a lock keeps
Arrange and Auto-Orient from doing, a plate's settings, the filament slot commands and the plate icons and menu,
`tools/mcp/tests/calibration.json` every calibration test and its preset answers,
`tools/mcp/tests/dialogs_canvas_input.json` auto-answers that run a button's handler and canvas
targets on negative parts and from below the bed, `tools/mcp/tests/slice_stats.json` the slice
reply's statistics on one and two colours, `tools/mcp/tests/preview.json` `plate_slice_stats`,
`app_state.preview` and `view_set`'s preview arguments, `tools/mcp/tests/context_menus.json` context
and button menus listed and run without one ever showing, and the Edit menu's Undo and Redo picked by
their paths, `tools/mcp/tests/rows.json` object list
rows, checklist rows, the object settings table and the print button's popup,
`tools/mcp/tests/recording.json` a recording with clicks, a dialog and a slice, stopped and encoded,
and one a replay ends, `tools/mcp/test_webview_modal.py` JavaScript in modal dialogs' web views, the ones
`webview_run_javascript` is refused in and a page that closes its dialog, `tools/mcp/tests/web_dialogs.json` the preset bundle dialog, the colour picker
(hex field and spectrum) and the setup wizard's first steps through the GUI tools alone,
`tools/mcp/test_calibration.py` every calibration test, its preset answers and its towers in the G-code,
`tools/mcp/test_slice_preview.py` what a slice slices and reports on one and two colours, `plate_slice_stats`,
`app_state.preview` and `view_set`'s preview arguments, `tools/mcp/test_gui_tools.py` context and button menus
listed and run without one ever showing, the Edit menu's Undo and Redo picked by their paths, object list rows,
checklist rows, the object settings table, the print button's popup, and the preset bundle dialog, the colour
picker (hex field and spectrum) and the setup wizard's first steps through the GUI tools alone,
`tools/mcp/test_recording.py` a recording with clicks, a dialog and a slice, stopped and encoded, and one a replay
ends, `tools/mcp/test_webview_modal.py` JavaScript in modal dialogs' web views, the ones
`webview_run_javascript` is refused in and a page that closes its dialog,
`tools/mcp/test_web_ui.py` every page control kind, action, refusal, locator, timeout and close of
the MCP web fixture plugin's dialog, window, dock panel and configuration UI (side-loaded with
`--install DATADIR`), `tools/mcp/test_set_view_preview.py` the
@@ -4680,17 +4685,16 @@ instruments going off with the server,
`tools/mcp/test_recovery_under_load.py` answering a dialog while stalled clients hold every
connection. See `tools/mcp/README.md`.
The commands that do a menu item's job by index, and the gaps they close, have their checks on the app. The
replays `tools/mcp/tests/menu_items_objects.json`, `menu_items_structure.json` and `menu_items_placement.json`,
and for the plates `tools/mcp/test_plates.py`, call the commands made from menu items by index and on the
selection, and read each back; `objects_state.json` (printable, Fix Model, Auto Drop), `objects_files.json` (clone, reload, replace),
`objects_order.json` (`object_order {order}`), `filaments_and_files.json` (slots merged and mixed, exports of
some objects, a ZIP's entries), `settings_targets.json` (`settings_list` and the targets of the settings
commands), `presets_and_plate_map.json` (`preset_list`'s filters, a plate's filament map, a nozzle variant),
`view_switches.json` (`view_set`'s switches, the sidebar and the legend, a plate's origin and size) and
`actions_ask.json` (a call with an action's arguments, the two actions that collect a value, and the actions
whose menu item is the command's function). The Python tests check what a replay cannot, a refusal:
`tools/mcp/test_menu_items_refusals.py` and `test_additions_refusals.py` each refusal's reason,
The commands that do a menu item's job by index, and the gaps they close, have their checks on the app.
`tools/mcp/test_objects.py` and `test_object_structure.py`, and for the plates `tools/mcp/test_plates.py`, call the
commands made from menu items by index and on the selection, and read each back, printable, Fix Model, Auto Drop,
clone, reload, replace and `object_order {order}` among them; `test_files.py` checks the project's files (slots
merged and mixed, exports of some objects, a ZIP's entries), `test_settings.py` `settings_list` and the targets of
the settings commands, `test_presets.py` `preset_list`'s filters, a plate's filament map and a nozzle variant,
`test_slice_preview.py` `view_set`'s switches, the sidebar and the legend, and `test_call_forms.py` a call with an
action's arguments and the forms agents write in place of the schema's. Others check the refusals and what
needs a launch of its own: `tools/mcp/test_menu_items_refusals.py` and `test_additions_refusals.py` each refusal's
reason,
`test_person_forms.py` the person's forms and a pick that runs in place, `test_preferences.py` the
preferences against the dialog, `test_install_printers.py` and `test_install_filaments.py` the installs, also
after a restart, `test_plugin_commands.py` the plugin commands against the Plugins window,
@@ -4709,11 +4713,10 @@ sizes, the object structure commands' arguments, the height ranges `object_set_h
overlaps, a range that keeps its settings) and the keys and layer heights a range's settings take, and
`plate_set_custom_gcode`'s edits of a layer slider built in the test (by layer
and height, in-place edits, refusals that leave the slider as it was, the type names). On the app,
`tools/mcp/tests/scene.json` checks object structure and placement (transform on instances, plates and
parts, what `object_list` reports of them, the selection `object_select` and `app_state` report, shapes at a
size, arrange and Fill bed, `part_add`, the
object structure commands, then all of them on one scene through to a slice);
`tools/mcp/tests/layers.json` height range modifiers and variable layer height profiles (set, read
`tools/mcp/test_objects.py` and `test_object_structure.py` check object placement and structure (transforms on
instances, plates and parts, what `object_list` reports of them, the selection `object_select` and `app_state`
report, shapes at a size, arrange and Fill bed, `part_add`, the object structure commands);
`tools/mcp/test_slice_preview.py` height range modifiers and variable layer height profiles (set, read
back, undone, sliced, refused, kept by a 3MF) and layer G-codes (placed by layer and height, edited in
place, refused, sliced, kept by a 3MF); and `tools/mcp/test_worker_admission.py` admission while an
arrange started three ways runs.
+3 -3
View File
@@ -3268,7 +3268,7 @@ void GLCanvas3D::_render_frame(bool scene_dirty, bool only_init)
const bool render_gcode = m_canvas_type == ECanvasType::CanvasPreview && m_render_preview;
// Slider moves made since the last frame reach the toolpaths before they are drawn, so a frame drawn
// right after a move, such as a screenshot, shows it.
if (render_gcode && _apply_gcode_sliders())
if (render_gcode && apply_gcode_sliders())
scene_dirty = true;
// Orca: found again by the regular picking pass, which is not run while dragging.
@@ -10912,11 +10912,11 @@ void GLCanvas3D::_render_gcode_overlay(int canvas_width, int canvas_height)
send_layer_ticks_changes();
// A slider dragged in this overlay moved after the scene was drawn; the next frame shows the move.
if (_apply_gcode_sliders())
if (apply_gcode_sliders())
post_event(SimpleEvent(EVT_GLCANVAS_UPDATE));
}
bool GLCanvas3D::_apply_gcode_sliders()
bool GLCanvas3D::apply_gcode_sliders()
{
IMSlider *layers_slider = m_gcode_viewer.get_layers_slider();
IMSlider *moves_slider = m_gcode_viewer.get_moves_slider();
+3 -2
View File
@@ -1138,6 +1138,9 @@ private:
public:
//BBS
GCodeViewer& get_gcode_viewer() { return m_gcode_viewer; }
// Hands the layers and moves sliders' positions to the toolpaths, which otherwise take them when the canvas next
// draws. Returns whether either slider had moved.
bool apply_gcode_sliders();
void init_gcode_viewer(ConfigOptionMode mode, Slic3r::PresetBundle* preset_bundle) { m_gcode_viewer.init(mode, preset_bundle); }
void reset_gcode_toolpaths() { _set_shown_canvas_current(); m_gcode_viewer.reset(); }
const GCodeViewer::SequentialView& get_gcode_sequential_view() const { return m_gcode_viewer.get_sequential_view(); }
@@ -1731,8 +1734,6 @@ private:
// Realistic view: binds, or unbinds, the shadow map the toolpaths read on texture unit 4. False without a map.
bool _bind_gcode_shadow_map(bool bind) const;
void _render_gcode_overlay(int canvas_width, int canvas_height);
// Hands the layers and moves sliders' positions to the toolpaths. Returns whether either slider had moved.
bool _apply_gcode_sliders();
// decides whether the preview draws its reduced set this frame and returns whether what the scene
// pass draws changed; runs before the cached scene is consulted
bool _update_preview_interaction();
+4 -2
View File
@@ -124,9 +124,11 @@ GuardState AutomationRuntime::guards_on_ui() const
GuardState g;
g.closing = m_stopping || wxTheApp == nullptr || wxGetApp().is_closing();
g.suspended = m_suspended;
// Whether a dialog is open is all a guard needs. Describing the dialogs reads every control of each, so it is left
// to the replies that name them (UiInvoker's open_dialogs()): made for every queued closure, it would keep the UI
// thread from the dialog's own events while many calls wait.
if (m_modals) {
g.dialogs = m_modals->snapshot();
g.modal = !g.dialogs.empty();
g.modal = m_modals->top() != nullptr;
g.top_dialog = m_modals->serial(m_modals->top());
}
return g;
+12
View File
@@ -18,6 +18,7 @@
#include <functional>
#include <memory>
#include <mutex>
#include <optional>
#include <set>
#include <string>
#include <system_error>
@@ -432,6 +433,8 @@ ToolResult McpCore::run(const NativeCommand& def, const nlohmann::json& args, co
budget = std::min(budget, m_timing.reply_budget_cap);
const auto deadline = start + budget;
auto next_probe = start + m_timing.soft_budget;
// The dialog the last probe found on top of the job, which a second probe must find there too.
std::optional<std::uint64_t> seen_on_top;
for (;;) {
const auto now = std::chrono::steady_clock::now();
const auto stop = std::min(deadline, next_probe);
@@ -452,8 +455,17 @@ ToolResult McpCore::run(const NativeCommand& def, const nlohmann::json& args, co
// A dialog can close between the probe and here; a finished job wins.
if (auto r = m_jobs.wait(job, std::chrono::milliseconds(0)))
return finish(std::move(*r));
// An auto-answer rule presses a wx dialog's button from a call queued as the dialog opens, which a
// probe queued before the dialog opened runs ahead of. A second probe, queued now, runs after that
// press, so a dialog holds the job only when the second probe still finds it on top.
if (seen_on_top != p->guards.top_dialog) {
seen_on_top = p->guards.top_dialog;
next_probe = std::chrono::steady_clock::now();
continue;
}
return finish(blocked(p->guards.dialogs, false));
}
seen_on_top.reset();
// An unanswered probe with a native dialog on top: that dialog holds the UI thread, so the
// snapshot published for other threads is all there is to report.
if (!p) {
+16 -4
View File
@@ -854,15 +854,17 @@ void register_project_tools(CommandCatalog& catalog)
throw ToolFailure("per_object writes every object into the folder path names: plates and overwrite go with one file");
if (format == "toolpaths_obj" && args.contains("plates"))
throw ToolFailure("toolpaths_obj writes the toolpaths the Preview shows: plates goes with the other formats");
const json plate = args.value("plates", json("current"));
const bool all = plate.is_string() && plate.get<std::string>() == "all";
if (plate.is_string() && !all && plate.get<std::string>() != "current")
throw ToolFailure("plates is \"all\", \"current\" or a plate index");
if (all && format != "sliced_3mf")
throw ToolFailure("plates \"all\" applies to sliced_3mf only");
std::string err;
const auto path = per_object ? resolve_output_dir(arg_string(args, "path"), err) :
resolve_output_path(arg_string(args, "path"), arg_bool(args, "overwrite", false), err);
if (!path)
throw ToolFailure(err);
const json plate = args.value("plates", json("current"));
const bool all = plate.is_string() && plate.get<std::string>() == "all";
if (all && format != "sliced_3mf")
throw ToolFailure("plates \"all\" applies to sliced_3mf only");
std::optional<Ops::ExportTicket> ticket;
json written = json::object(); // what the reply adds for stl and drc
ctx.run_ui([&]() -> json {
@@ -871,6 +873,16 @@ void register_project_tools(CommandCatalog& catalog)
ctx.begin_operation();
Plater& plater = ui_plater();
const std::optional<int> index = plate.is_number_integer() ? std::optional<int>(plate.get<int>()) : std::nullopt;
// The export's own refusals of the object indices given come before the target check, which
// refuses an index the project lacks without no_such_object's code.
std::vector<int> indices;
if (args.contains("object") && args.at("object").is_number_integer())
indices.push_back(args.at("object").get<int>());
for (const json& entry : args.value("objects", json::array()))
if (entry.is_number_integer())
indices.push_back(entry.get<int>());
if (const std::optional<Ops::Refusal> refusal = Ops::export_objects_refusal(format, indices, per_object, plater.model()))
throw refused(*refusal);
// The objects named, by index or id; none named: every object.
Targets named;
if (names_targets(args)) {
+6 -2
View File
@@ -1864,7 +1864,8 @@ void register_object_menu_commands(CommandCatalog& catalog)
"actions, it shows the Prepare view and, as Order By does, reverses the order the objects already have. "
"With order in place of by, the plate's objects go in the order given, as dragging them in the object list "
"puts them: order names each of the plate's objects once, by index, and anything else is refused; the "
"other plates' objects keep their order. One undo step; object indices change. Reply: the new order (order: "
"other plates' objects keep their order. One undo step, none when the order stays as it was; object indices "
"change. Reply: the new order (order: "
"[{object, name, plate}]), and descending with by.",
object_schema({{"plate", {{"type", "integer"}, {"minimum", 0}, {"description", "Order this plate's objects. Default: the current plate."}}},
{"by", enum_prop({"name", "filament", "height", "size"}, "What to order by.")},
@@ -2320,7 +2321,8 @@ void register_object_tools(CommandCatalog& catalog)
"file. A part whose file is gone is not asked for: it is listed under missing. A part keeps its settings, type, "
"filament and placement, and its painting when the keep_painting preference is on. Parts loaded from no file "
"(primitives, the built-in models) are left out; cut objects are refused, since a reload would replace a cut part "
"with its whole file, and so is a call while a gizmo is open. One undo step. Reply: reloaded (parts), missing "
"with its whole file, and so is a call while a gizmo is open. One undo step, none when every part's file is "
"missing and nothing is reloaded. Reply: reloaded (parts), missing "
"(with each part's path), unmatched (parts their file holds no part to take for) and unreadable (a file that "
"could not be read, after which nothing more was loaded).",
with_targets(object_schema({{"all", prop("boolean", "Reload every object but the cut ones. Default false: the targets.")}}),
@@ -2714,6 +2716,8 @@ void register_scene_tools(CommandCatalog& catalog)
"Preview and Slice All Plates actions.")}}),
[](const json& args, ToolContext& ctx) {
const json plates_arg = args.value("plates", json("current"));
if (plates_arg.is_string() && plates_arg != "all" && plates_arg != "current")
throw ToolFailure("plates is \"all\", \"current\" or a plate index");
auto ticket = std::make_shared<SliceTicket>();
// Held from before the wait below, so no call admitted meanwhile can change the project
// under the slice, and a cancel meanwhile finds the operation.
+2 -1
View File
@@ -1598,7 +1598,8 @@ void register_ui_tools(CommandCatalog& catalog)
"selects it; false on the "
"selected one is refused, as only selecting another unselects it). "
"ImGui items, by their kind, with the value read back: a field is typed into (a slider through the number field "
"beside it, multiline text with \\n), a combo's option is picked by its text or 0-based index, and a checkbox, radio "
"beside it, multiline text with \\n), and one that then shows another value, the edit in its own terms or bounded, "
"replies typed and a note beside it; a combo's option is picked by its text or 0-based index, and a checkbox, radio "
"or toggle is clicked when it differs. A web page's fields, as typing would leave them: text, number, range, colour "
"and date fields and editable text get the value with input and change events (submit then leaves the field; "
"keyboard_press Return presses Enter), a select its option by text, value or index, and a checkbox or radio is clicked when "
+7 -1
View File
@@ -3514,8 +3514,14 @@ json UiInspector::imgui_input(UiTarget t, const json& value, bool submit)
key(&field, "Return", "");
}
const std::string shown = imgui_record(field).value;
// A field can show the edit it took in its own terms (the Move panel's Object coordinates measure from the place
// the object moved to, an angle may read as an equal one) or bounded: what it shows is the reply, with the text
// typed beside it, and no error, which would have a caller make the edit again.
if (!imgui_value_matches(shown, field_kind == "multiline" ? json(text) : value))
throw ToolFailure("\"" + t.imgui_label + "\" shows \"" + shown + "\" after typing \"" + text + "\"", {{"value", shown}});
return {{"value", shown},
{"typed", text},
{"note", "The field shows another value than the one typed: it shows the edit in its own terms or bounded it. Read the "
"model back to see what changed."}};
return {{"value", shown}};
}
+6 -2
View File
@@ -99,7 +99,7 @@ nlohmann::json UiInvoker::run(GuardClass guard, const std::string& tool, const s
error = "The UI was recreated (language change) before the call ran; it was not run, so it is safe to retry";
else if (guard == GuardClass::Mutate && g.modal) {
error = "A modal dialog is open; answer it first (widget_list, dialog_answer)";
details = {{"dialogs", g.dialogs}};
details = {{"dialogs", shared->open_dialogs ? shared->open_dialogs() : g.dialogs}};
} else if (guard == GuardClass::Mutate && !shared->running_tools.empty())
error = "Busy: " + shared->running_tools.front() + " is still running; only inspection and dialog tools can run now";
}
@@ -170,6 +170,9 @@ std::optional<UiInvoker::Probe> UiInvoker::probe(std::chrono::milliseconds timeo
p.running_tool = shared->running_tools.front();
if (!shared->stopped && shared->guards_on_ui)
p.guards = shared->guards_on_ui();
// A dialog the probe finds is reported, so it is described, as it is now.
if (p.guards.modal && shared->open_dialogs)
p.guards.dialogs = shared->open_dialogs();
{
std::lock_guard<std::mutex> lock(call->mutex);
call->probe = std::move(p);
@@ -190,7 +193,8 @@ void UiInvoker::require_mutate() const
if (m_shared->guards_on_ui) {
const GuardState g = m_shared->guards_on_ui();
if (g.modal)
throw ToolFailure("A modal dialog is open; answer it first (widget_list, dialog_answer)", {{"dialogs", g.dialogs}});
throw ToolFailure("A modal dialog is open; answer it first (widget_list, dialog_answer)",
{{"dialogs", m_shared->open_dialogs ? m_shared->open_dialogs() : g.dialogs}});
}
if (m_shared->running_tools.size() > 1)
throw ToolFailure("Busy: " + m_shared->running_tools.front() +
+1 -1
View File
@@ -29,7 +29,7 @@ struct GuardState
bool closing = false; // the app is shutting down
bool suspended = false; // the main frame is being recreated (language change)
bool modal = false; // a modal dialog or an ImGui modal popup is open
nlohmann::json dialogs = nlohmann::json::array();
nlohmann::json dialogs = nlohmann::json::array(); // the open dialogs where the guards describe them; replies read open_dialogs()
std::uint64_t top_dialog = 0; // the topmost modal dialog's serial (ModalTracker::serial()), 0 for none
};
+44 -3
View File
@@ -54,10 +54,51 @@ using namespace std::chrono_literals;
namespace {
// Sends `request` to `web`'s agent and hands the outcome to `done` on the UI thread; a page without
// the agent (or with another version) is sent it with the request once. UI thread only.
void call_page(wxWebView* web, const json& request, std::function<void(PageReply)> done, bool install = false)
void call_page(wxWebView* web, const json& request, std::function<void(PageReply)> done, bool install = false,
bool wait_for_page = true);
// Holds a page request while its web view has no native view to run a script in, which WebView2 creates a moment
// after the window opens, and sends it once the view is there: tried every 100 ms for up to 10 s, the time a page
// gets to answer by default. UI thread only; it deletes itself.
class PageWait : public wxTimer
{
public:
PageWait(wxWebView* web, json request, std::function<void(PageReply)> done, bool install)
: m_web(web), m_request(std::move(request)), m_done(std::move(done)), m_install(install)
{}
void Notify() override
{
wxWebView* web = m_web.get();
if (web != nullptr && web->GetNativeBackend() == nullptr && ++m_tries < 100)
return;
Stop();
if (web == nullptr)
m_done(PageReply{PageReply::State::Destroyed, json(), std::string()});
else
call_page(web, m_request, std::move(m_done), m_install, false);
// Not from inside the timer's own callback, which wx may still touch afterwards.
if (wxTheApp != nullptr)
wxTheApp->CallAfter([this] { delete this; });
}
private:
wxWeakRef<wxWebView> m_web;
json m_request;
std::function<void(PageReply)> m_done;
bool m_install;
int m_tries = 0;
};
// Sends `request` to `web`'s agent and hands the outcome to `done` on the UI thread; a page without
// the agent (or with another version) is sent it with the request once, and a web view whose native view
// is not made yet, once it is (PageWait). UI thread only.
void call_page(wxWebView* web, const json& request, std::function<void(PageReply)> done, bool install, bool wait_for_page)
{
if (wait_for_page && web->GetNativeBackend() == nullptr) {
(new PageWait(web, request, std::move(done), install))->Start(100);
return;
}
wxWeakRef<wxWebView> weak = web;
WebView::RunScriptAsync(web, from_u8(page_script(request, install)),
[weak, request, install, done = std::move(done)](bool ok, const std::string& text) {
+75 -19
View File
@@ -4,6 +4,7 @@
#include "PlateOps.hpp"
#include "RunStatus.hpp"
#include "slic3r/GUI/GLCanvas3D.hpp"
#include "slic3r/GUI/GUI.hpp"
#include "slic3r/GUI/GUI_App.hpp"
#include "slic3r/GUI/I18N.hpp"
@@ -54,6 +55,48 @@ std::optional<Refusal> select_named_plate(const std::optional<int>& plate)
return selected ? std::nullopt : std::optional<Refusal>(selected.refusal());
}
// An export that selected the plate it named and then failed makes the plate that was current before current
// again, so that a failed export leaves the current plate as it was. Both selections stay in the undo history.
template<class T> T select_back(const std::optional<int>& named, int previous, T failure)
{
if (named && *named != previous)
wxGetApp().plater()->select_plate(previous);
return failure;
}
Refusal export_already_running() { return {RefusalKind::Busy, "export_already_running", L("Another export job is running.")}; }
Refusal slicing_in_progress()
{
return {RefusalKind::Busy, "slicing_in_progress", L("Slicing is in progress. Wait for it to finish and export again.")};
}
Refusal slice_has_errors()
{
return {RefusalKind::Precondition, "slice_has_errors",
L("The plate's slice ended with an error. Fix what it reports and slice again before exporting.")};
}
Refusal plate_not_sliced() { return {RefusalKind::Precondition, "plate_not_sliced", L("The plate is not sliced. Slice it first.")}; }
Refusal export_not_started() { return {RefusalKind::Failed, "export_not_started", L("The export did not start.")}; }
Refusal sliced_file_not_written()
{
return {RefusalKind::Precondition, "sliced_file_not_written",
L("The sliced file was not written. Slice first and check for slicing errors.")};
}
// What Plater::export_gcode_to() would refuse on `plate`, in its order, asked before the export selects the plate
// so that a refused export changes nothing.
std::optional<Refusal> gcode_export_refusal(Plater& plater, int plate)
{
if (plater.is_export_gcode_scheduled())
return export_already_running();
if (plater.is_slicing_any())
return slicing_in_progress();
if (!plater.plate_validation_error(plate).empty())
return slice_has_errors();
if (!plater.get_partplate_list().get_plate(plate)->is_slice_result_valid())
return plate_not_sliced();
return std::nullopt;
}
} // namespace
Outcome<ExportTicket> start_gcode_export(const ExportGcodeArgs& args)
@@ -63,9 +106,12 @@ Outcome<ExportTicket> start_gcode_export(const ExportGcodeArgs& args)
PartPlateList& plates = plater.get_partplate_list();
if (plater.model().objects.empty())
return no_objects();
const int previous = plates.get_curr_plate_index();
if (args.plate) {
if (*args.plate < 0 || *args.plate >= plates.get_plate_count())
return no_such_plate(*args.plate, plates.get_plate_count());
if (std::optional<Refusal> refusal = gcode_export_refusal(plater, *args.plate))
return *refusal;
// The owner exports the current plate.
plater.select_plate(*args.plate);
}
@@ -74,23 +120,21 @@ Outcome<ExportTicket> start_gcode_export(const ExportGcodeArgs& args)
ticket.seq_before = plater.export_seq();
ticket.revision = plater.project_revision();
ticket.path = args.path.string();
std::optional<Refusal> refusal;
switch (plater.export_gcode_to(args.path)) {
case Plater::ExportRefusal::None: break;
case Plater::ExportRefusal::NoObjects: return no_objects();
case Plater::ExportRefusal::AlreadyExporting:
return Refusal{RefusalKind::Busy, "export_already_running", L("Another export job is running.")};
case Plater::ExportRefusal::Slicing:
return Refusal{RefusalKind::Busy, "slicing_in_progress", L("Slicing is in progress. Wait for it to finish and export again.")};
case Plater::ExportRefusal::SliceHasErrors:
return Refusal{RefusalKind::Precondition, "slice_has_errors",
L("The plate's slice ended with an error. Fix what it reports and slice again before exporting.")};
case Plater::ExportRefusal::NotSliced:
return Refusal{RefusalKind::Precondition, "plate_not_sliced", L("The plate is not sliced. Slice it first.")};
case Plater::ExportRefusal::NotStarted: return Refusal{RefusalKind::Failed, "export_not_started", L("The export did not start.")};
case Plater::ExportRefusal::NoObjects: refusal = no_objects(); break;
case Plater::ExportRefusal::AlreadyExporting: refusal = export_already_running(); break;
case Plater::ExportRefusal::Slicing: refusal = slicing_in_progress(); break;
case Plater::ExportRefusal::SliceHasErrors: refusal = slice_has_errors(); break;
case Plater::ExportRefusal::NotSliced: refusal = plate_not_sliced(); break;
case Plater::ExportRefusal::NotStarted: refusal = export_not_started(); break;
}
ticket.seq_after = plater.export_seq();
if (ticket.seq_after == ticket.seq_before)
return Refusal{RefusalKind::Failed, "export_not_started", L("The export did not start.")};
if (!refusal && ticket.seq_after == ticket.seq_before)
refusal = export_not_started();
if (refusal)
return select_back(args.plate, previous, Outcome<ExportTicket>(*refusal));
return ticket;
}
@@ -112,21 +156,28 @@ Outcome<Done> export_sliced_3mf(const ExportSlicedArgs& args)
Plater& plater = *wxGetApp().plater();
if (plater.model().objects.empty())
return no_objects();
const int previous = plater.get_partplate_list().get_curr_plate_index();
// The named plate's slice error refuses before the plate is selected, as export_gcode_3mf() refuses it after.
if (args.plate && *args.plate >= 0 && *args.plate < plater.get_partplate_list().get_plate_count() &&
!plater.plate_validation_error(*args.plate).empty())
return sliced_file_not_written();
if (std::optional<Refusal> refusal = select_named_plate(args.plate))
return *refusal;
if (!plater.export_gcode_3mf(args.all_plates, args.path))
return Refusal{RefusalKind::Precondition, "sliced_file_not_written",
L("The sliced file was not written. Slice first and check for slicing errors.")};
return written(args.path);
return select_back(args.plate, previous, Outcome<Done>(sliced_file_not_written()));
const Outcome<Done> done = written(args.path);
return done ? done : select_back(args.plate, previous, done);
}
Outcome<Done> export_model_3mf(const ExportFileArgs& args)
{
assert(wxThread::IsMain());
const int previous = wxGetApp().plater()->get_partplate_list().get_curr_plate_index();
if (std::optional<Refusal> refusal = select_named_plate(args.plate))
return *refusal;
wxGetApp().plater()->export_core_3mf(from_path(args.path));
return written(args.path);
const Outcome<Done> done = written(args.path);
return done ? done : select_back(args.plate, previous, done);
}
std::optional<Refusal> export_objects_refusal(const std::string& format, const std::vector<int>& objects, bool per_object,
@@ -153,17 +204,19 @@ Outcome<std::vector<boost::filesystem::path>> export_stl(const ExportStlArgs& ar
return no_objects();
if (std::optional<Refusal> refusal = export_objects_refusal(args.draco ? "drc" : "stl", args.objects, args.per_object, plater.model()))
return *refusal;
const int previous = plater.get_partplate_list().get_curr_plate_index();
if (std::optional<Refusal> refusal = select_named_plate(args.plate))
return *refusal;
using Files = Outcome<std::vector<boost::filesystem::path>>;
std::vector<boost::filesystem::path> files;
for (const std::string& file :
plater.export_stl(false, false, args.per_object, args.draco ? FT_DRC : FT_STL, from_path(args.path), args.objects)) {
files.push_back(into_path(from_u8(file)));
if (!written(files.back()))
return file_not_written();
return select_back(args.plate, previous, Files(file_not_written()));
}
if (files.empty())
return file_not_written();
return select_back(args.plate, previous, Files(file_not_written()));
return files;
}
@@ -182,6 +235,9 @@ Outcome<Done> export_toolpaths_obj(const ExportToolpathsArgs& args)
assert(wxThread::IsMain());
if (std::optional<Refusal> refusal = toolpaths_refusal())
return *refusal;
// A layer range shown since the canvas last drew reaches the toolpaths only when it draws again: the file
// holds what the Preview shows.
wxGetApp().plater()->get_preview_canvas3D()->apply_gcode_sliders();
wxGetApp().plater()->export_toolpaths_to_obj(from_path(args.path));
return written(args.path);
}
+3 -1
View File
@@ -33,7 +33,9 @@ struct ExportTicket
};
// Selects the plate when one is given, then starts writing its G-code in the background and returns
// at once; gcode_export_state() says how the export stands.
// at once; gcode_export_state() says how the export stands. An export that names a plate and is refused
// leaves the current plate as it was: what can be told on the plate is refused before it is selected, and
// a failure after that selects the plate that was current back. The exports below do the same.
// Refuses: no_objects, no_such_plate, export_already_running, slicing_in_progress, slice_has_errors,
// plate_not_sliced, export_not_started.
Outcome<ExportTicket> start_gcode_export(const ExportGcodeArgs& args);
+8 -3
View File
@@ -1232,10 +1232,15 @@ void placed_instance(int object, int instance, bool drop)
{
Plater& plater = the_plater();
ModelObject& owner = *plater.model().objects[std::size_t(object)];
// The bounding box is cached: ensure_on_bed() must measure the new placement.
// The bounding box is cached: the drop must measure the new placement.
owner.invalidate_bounding_box();
if (drop)
owner.ensure_on_bed();
// Only the instance placed comes to rest on the bed, by its own lowest point, as the canvas drops the instances a
// move or scale changed: the object's other instances keep their heights.
if (drop && owner.auto_drop) {
const double min_z = owner.get_instance_min_z(std::size_t(instance));
if (min_z != 0.0)
owner.translate_instance(std::size_t(instance), Vec3d(0.0, 0.0, -min_z));
}
plater.get_partplate_list().notify_instance_update(object, instance);
wxGetApp().obj_list()->update_plate_values_for_items();
plater.changed_object(object);
+7 -6
View File
@@ -215,7 +215,8 @@ struct OrderObjectsArgs
std::optional<bool> descending; // none: descending when the order they have is ascending already, as Order By does
};
// Orders a plate's objects, or every plate's, as the plate menu's Order By does (ObjectList::order_objects()), which
// sets the object list and print order, in one undo step. Returns whether they are in descending order.
// sets the object list and print order, in one undo step, or none when the order stays as it was. Returns whether they
// are in descending order.
// Refuses: no_such_plate, no_objects_to_order, gizmo_open.
Outcome<bool> order_objects(const OrderObjectsArgs& args);
@@ -225,8 +226,8 @@ struct ReorderObjectsArgs
std::vector<int> order; // the plate's objects, each once, in the order wanted
};
// Puts a plate's objects in `order`, which sets the object list and print order, as dragging each in the object list
// onto the one in its place does (ObjectList::OnDrop(), the drops object_order_moves() gives), in one undo step. The
// objects of other plates keep their order. Returns the plate's objects, by their indices afterwards, in that order.
// onto the one in its place does (ObjectList::OnDrop(), the drops object_order_moves() gives), in one undo step, or none
// when the order stays as it was. The objects of other plates keep their order. Returns the plate's objects, by their indices afterwards, in that order.
// Refuses: no_such_plate, and what object_order_moves() refuses.
Outcome<std::vector<int>> reorder_objects(const ReorderObjectsArgs& args);
@@ -470,7 +471,7 @@ struct ReloadedParts
// Reloads the targets' parts from their files (reload_sources()), as Reload from disk does
// (Plater::reload_parts_from_disk()), in one "Reload from disk" undo step: each keeps its settings, type, filament and
// placement, and its painting with the keep_painting preference on. A part whose file is gone is listed as missing; no
// dialog opens.
// dialog opens. A call that reloads nothing, every part's file being missing, takes no undo step.
// Refuses: gizmo_open (a gizmo is open), cut_object (a cut object named: a reload would replace a cut part with its whole
// file), no_objects (all, with none that is not cut), no_source (none of the parts was loaded from a file).
Outcome<ReloadedParts> reload_parts(const ReloadFromDiskArgs& args);
@@ -500,8 +501,8 @@ struct ReplacePartArgs
// cancelled), several_parts (replacement_refusal()).
Outcome<int> replace_part(const ReplacePartArgs& args);
// Brings the app up to date with instance `instance` of object `object`, placed anew in the model: dropped onto the bed
// with `drop`, its plate registered (slicing and the object list read the plate from the registry, which a move on the
// Brings the app up to date with instance `instance` of object `object`, placed anew in the model: with `drop` and the
// object's Auto Drop on, the instance alone set on the bed by its lowest point, its plate registered (slicing and the object list read the plate from the registry, which a move on the
// canvas updates) and the object reloaded. UI thread.
void placed_instance(int object, int instance, bool drop);
+11 -3
View File
@@ -13,6 +13,7 @@
#include "slic3r/GUI/Plater.hpp"
#include "libslic3r/Config.hpp"
#include "libslic3r/GCode/GCodeProcessor.hpp"
#include "libslic3r/Model.hpp"
#include <algorithm>
@@ -267,9 +268,16 @@ LayerTicks layer_ticks(std::optional<int> first, int last, int count)
Outcome<int> layer_count()
{
GLCanvas3D* canvas = the_plater().get_preview_canvas3D();
IMSlider* layers = canvas != nullptr ? canvas->get_gcode_viewer().get_layers_slider() : nullptr;
// The slider's range alone says nothing: it starts at 0..100 before a print gives it its layers.
if (layers == nullptr || layers->values_count() == 0)
if (canvas == nullptr)
return no_layers();
GCodeViewer& viewer = canvas->get_gcode_viewer();
IMSlider* layers = viewer.get_layers_slider();
const GCodeProcessorResult* result = the_plater().get_partplate_list().get_curr_plate()->get_slice_result();
// The slider alone says nothing: its range starts at 0..100 before a print gives it layers, and the Preview
// hides it without clearing it for a plate that has none. Only a viewer that holds the current plate's
// toolpaths has the layers of that plate, the test app_state's preview makes too.
if (layers == nullptr || layers->values_count() == 0 || result == nullptr || !viewer.has_data() ||
viewer.last_result_id() != result->id)
return no_layers();
return layers->GetMaxValue() + 1;
}
+4 -4
View File
@@ -134,10 +134,10 @@ Outcome<std::vector<int>> slice_plates(const SliceArgs& args);
// Refuses: no_such_plate.
Outcome<SliceTicket> start_slice(const SliceArgs& args);
// How many layers the Preview has to show, for a caller that turns an argument of its own into a
// layer. The slider keeps the last slice's layers until another slice replaces them, so a plate that
// is empty or not sliced can still have layers to show.
// Refuses: no_layers (the layer slider is absent or was given no layers, as before the first slice).
// How many layers the Preview has to show of the current plate, for a caller that turns an argument of
// its own into a layer.
// Refuses: no_layers (the Preview does not hold the current plate's toolpaths: the plate is empty, not
// sliced, or its slice failed).
Outcome<int> layer_count();
struct ShowLayerRangeArgs
+3 -1
View File
@@ -130,8 +130,10 @@ void show_default_filaments(PresetBundle& bundle, const std::string& printer_nam
// names the slot whose selector it is, 0 for a tab's.
Refusal not_offered(PresetCollection& presets, const std::string& name, int filament_slot)
{
// Incompatible only when no compatible preset carries the name: one that does is listed under another name (an
// alias such as "0.16mm Optimal" names presets for many printers), which the similar names point to.
if (const std::vector<Preset*> incompatible = presets_named(presets, name, [](const Preset& p) { return !p.is_compatible; });
!incompatible.empty())
!incompatible.empty() && presets_named(presets, name, [](const Preset& p) { return p.is_compatible; }).empty())
return {RefusalKind::Precondition, "preset_incompatible", L("\"%1%\" is not compatible with the selected printer."), {name},
names_of(incompatible)};
if (filament_slot > 0)
+2 -2
View File
@@ -52,8 +52,8 @@ struct ResolvedPreset
// internal names. A hidden compatible preset the name stands for is shown in the selectors first, and
// stays shown until the app restarts, whatever comes of the call after it.
// Refuses: mixed_filament_slot, no_such_slot, ambiguous_preset_name, ambiguous_hidden_preset (with the
// candidates), preset_incompatible (with the incompatible presets of that name),
// preset_not_offered (with the closest names).
// candidates), preset_incompatible (with the incompatible presets of that name, when no
// compatible preset carries it), preset_not_offered (with the closest names).
Outcome<ResolvedPreset> resolve_preset(const ResolvePresetArgs& args);
struct SelectPresetArgs
+4
View File
@@ -125,6 +125,10 @@ Outcome<ImportModelsResult> import_models(const ImportModelsArgs& args)
plater.import_zip_archive(archive.path, &archive.entries);
if (plater.model().objects.size() == before)
return Refusal{RefusalKind::Failed, "nothing_loaded", L("Nothing was imported.")};
// Named as File > Import names it, after the first model file; an archive alone names nothing, as Import ZIP
// Archive names nothing.
if (!files.empty())
plater.name_untitled_project(files.front());
result.added = plater.model().objects.size() - before;
return result;
}
+2 -1
View File
@@ -59,7 +59,8 @@ struct ImportModelsResult
// are not loaded), as one "Import Objects: <files>" undo step. A .zip archive is taken apart as Import
// ZIP Archive does (Plater::import_zip_archive()): the files `entries` names, or every model file it
// holds, in place of its file list. The owner's import can open a dialog of its own (a STEP file's
// mesh options).
// mesh options). An untitled project is named after the first file that is not an archive, as File >
// Import names it.
// Refuses: unreadable_archive and what zip_entries_refusal() gives, before anything is imported;
// nothing_loaded. The undo step stays in the history then, as after an import from the File menu
// whose load fails.
+9
View File
@@ -18979,6 +18979,15 @@ wxString Plater::get_project_name()
return p->get_project_name();
}
void Plater::name_untitled_project(const boost::filesystem::path& file)
{
// The test add_file() makes: a new project's name is the translated "Untitled".
if (get_project_name() != _L("Untitled"))
return;
p->set_project_name(from_u8(file.stem().string()));
wxGetApp().mainframe->update_title();
}
void Plater::update_all_plate_thumbnails(bool force_update)
{
for (int i = 0; i < get_partplate_list().get_plate_count(); i++)
+3
View File
@@ -494,6 +494,9 @@ public:
// BBS
bool is_new_project_and_check_state() { return m_new_project_and_check_state; }
wxString get_project_name();
// Names an untitled project after `file` without its extension and shows the name in the title, as File >
// Import does after its first model loads; the project keeps no file. A project with a name keeps it.
void name_untitled_project(const boost::filesystem::path& file);
void update_all_plate_thumbnails(bool force_update = false);
void update_plate_thumbnails(int plate_idx, bool force_update);
void update_obj_preview_thumbnail(ModelObject *, int obj_idx, int vol_idx, std::vector<Slic3r::ColorRGBA> colors, int camera_view_angle_type);
+22
View File
@@ -392,6 +392,28 @@ TEST_CASE("blocked_by_dialog is reported after the soft budget when the probe se
CHECK(result->data["closed"] == true);
}
TEST_CASE("a dialog whose answer was queued as it opened does not hold the call", "[Mcp]")
{
Harness h;
h.registry.add(tool("answered_modal", GuardClass::Mutate, [&](const json&, ToolContext& ctx) {
ctx.run_ui([&] {
// Past the 100 ms soft budget the first probe is queued behind this closure. The dialog then
// opens and queues its answer behind that probe, as an auto-answer rule queues its press.
std::this_thread::sleep_for(250ms);
std::atomic<bool> answered{false};
h.ui.post([&] { answered = true; });
h.modal_loop(answered, json::array({{{"title", "Orca Slicer info"}}}));
return json();
});
return ToolResult::ok({{"closed", true}});
}));
h.start();
const ToolResult r = h.call("answered_modal");
CHECK(r.data.value("status", "") != "blocked_by_dialog");
CHECK(r.data.value("closed", false) == true);
}
TEST_CASE("a call working in the topmost dialog is blocked only by another dialog on top", "[Mcp]")
{
Harness h;
+3 -3
View File
@@ -2386,7 +2386,7 @@
}
],
"completion": "immediate",
"description": "Order the objects of a plate (the current one, or plate), or with all of every plate, by name, filament, height or size (bounding box volume), which sets the object list and print order, as the plate menu's Order By does: ascending, or with descending true descending. Called with by alone, as its Speed Dial actions, it shows the Prepare view and, as Order By does, reverses the order the objects already have. With order in place of by, the plate's objects go in the order given, as dragging them in the object list puts them: order names each of the plate's objects once, by index, and anything else is refused; the other plates' objects keep their order. One undo step; object indices change. Reply: the new order (order: [{object, name, plate}]), and descending with by.",
"description": "Order the objects of a plate (the current one, or plate), or with all of every plate, by name, filament, height or size (bounding box volume), which sets the object list and print order, as the plate menu's Order By does: ascending, or with descending true descending. Called with by alone, as its Speed Dial actions, it shows the Prepare view and, as Order By does, reverses the order the objects already have. With order in place of by, the plate's objects go in the order given, as dragging them in the object list puts them: order names each of the plate's objects once, by index, and anything else is refused; the other plates' objects keep their order. One undo step, none when the order stays as it was; object indices change. Reply: the new order (order: [{object, name, plate}]), and descending with by.",
"destructive": false,
"group": "Objects",
"guard": "mutate",
@@ -3082,7 +3082,7 @@
},
{
"completion": "immediate",
"description": "Load parts again from the files they were loaded from, as Reload from disk does: every part of the objects named, the parts named, every object's (all, as Reload All does, cut objects left out), else what is selected in the Prepare view. A part's file is the one it was loaded from, else the file of that name beside its object's file. A part whose file is gone is not asked for: it is listed under missing. A part keeps its settings, type, filament and placement, and its painting when the keep_painting preference is on. Parts loaded from no file (primitives, the built-in models) are left out; cut objects are refused, since a reload would replace a cut part with its whole file, and so is a call while a gizmo is open. One undo step. Reply: reloaded (parts), missing (with each part's path), unmatched (parts their file holds no part to take for) and unreadable (a file that could not be read, after which nothing more was loaded).",
"description": "Load parts again from the files they were loaded from, as Reload from disk does: every part of the objects named, the parts named, every object's (all, as Reload All does, cut objects left out), else what is selected in the Prepare view. A part's file is the one it was loaded from, else the file of that name beside its object's file. A part whose file is gone is not asked for: it is listed under missing. A part keeps its settings, type, filament and placement, and its painting when the keep_painting preference is on. Parts loaded from no file (primitives, the built-in models) are left out; cut objects are refused, since a reload would replace a cut part with its whole file, and so is a call while a gizmo is open. One undo step, none when every part's file is missing and nothing is reloaded. Reply: reloaded (parts), missing (with each part's path), unmatched (parts their file holds no part to take for) and unreadable (a file that could not be read, after which nothing more was loaded).",
"destructive": false,
"examples": [
{
@@ -18125,7 +18125,7 @@
},
{
"completion": "immediate",
"description": "Set a widget's value and send the events a person's edit would. Widgets: text fields (submit, the default, also presses Enter and leaves the field, which is when Orca's setting fields commit), spin controls, sliders, choice, combo and list boxes (by option text or index), checkboxes, toggles and a row's checkbox (true or false), and a radio button (an Orca radio box too) or a selector's option, as the dialog message shows them (*) / ( ) (true selects it; false on the selected one is refused, as only selecting another unselects it). ImGui items, by their kind, with the value read back: a field is typed into (a slider through the number field beside it, multiline text with \\n), a combo's option is picked by its text or 0-based index, and a checkbox, radio or toggle is clicked when it differs. A web page's fields, as typing would leave them: text, number, range, colour and date fields and editable text get the value with input and change events (submit then leaves the field; keyboard_press Return presses Enter), a select its option by text, value or index, and a checkbox or radio is clicked when it differs; the value is read back and page says what changed, as for widget_click. File fields can't be set. For settings, settings_set is more reliable.",
"description": "Set a widget's value and send the events a person's edit would. Widgets: text fields (submit, the default, also presses Enter and leaves the field, which is when Orca's setting fields commit), spin controls, sliders, choice, combo and list boxes (by option text or index), checkboxes, toggles and a row's checkbox (true or false), and a radio button (an Orca radio box too) or a selector's option, as the dialog message shows them (*) / ( ) (true selects it; false on the selected one is refused, as only selecting another unselects it). ImGui items, by their kind, with the value read back: a field is typed into (a slider through the number field beside it, multiline text with \\n), and one that then shows another value, the edit in its own terms or bounded, replies typed and a note beside it; a combo's option is picked by its text or 0-based index, and a checkbox, radio or toggle is clicked when it differs. A web page's fields, as typing would leave them: text, number, range, colour and date fields and editable text get the value with input and change events (submit then leaves the field; keyboard_press Return presses Enter), a select its option by text, value or index, and a checkbox or radio is clicked when it differs; the value is read back and page says what changed, as for widget_click. File fields can't be set. For settings, settings_set is more reliable.",
"destructive": false,
"group": "Driving the GUI",
"guard": "recover",
+93 -163
View File
@@ -235,95 +235,65 @@ the `pages.get()` above does. While a modal it opened is up, tool calls that cha
so interactive scripts use modeless windows. `docs/HLSD/mcp-server.md` ("Python scripts") has the rules for
overlapping runs, imports, pools, `atexit` and Stop.
`tests/gizmos.json` drives every gizmo through the GUI tools, the way a person does: each one's icon,
its panel's fields, combos, toggles and links, and clicks or strokes at points of the model, then
checks what it left on the model (`object_list`), with an undo and redo and a canvas screenshot per
gizmo. It uses the fixtures beside it (`tests/fixtures/star.svg`, `tests/fixtures/heightmap.png`).
Run it at a second window size through `replay_run`'s `vars`:
`test_gizmos.py` drives every gizmo through the GUI tools, the way a person does: each one's icon, its panel's
fields, combos, toggles and links, and clicks or strokes at points of the model. It reads each gizmo's work back from
the model it leaves (placements, painted facets, texture layers, text and SVG parts, brim ears), checks its undo
before any redo, and reads what a person keeps again from a saved and reopened project. It also checks the canvas
input the gizmos rely on (a press held across gestures, a toolbar item a selection has just enabled, points on a
negative part and seen from below the bed) and that auto-answer rules run the preset prompt's Transfer and Discard.
It uses the fixtures beside it (`tests/fixtures/star.svg`, `tests/fixtures/heightmap.png`), and scenarios named on
its command line run alone.
```bash
tools/mcp/orca_mcp.py call replay_run '{"path": "/abs/tools/mcp/tests/gizmos.json", "out_dir": "/tmp/gizmos-small", "vars": {"window_size": [1100, 760]}}' --wait
```
`test_objects.py` and `test_object_structure.py` check the object commands, each called by index and, where its
menu item acts on the selection, on the selection. `test_objects.py` checks where objects stand and how many there
are: shapes added at a size, a place, a plate and a name; instances moved, turned, scaled and sent to another plate,
and what Auto Drop does to a move; parts moved and scaled; the selection; Mirror, Drop to Bed, Center, Scale to Fit
and Auto-Orient; the number of instances and Set as Individual Objects; Arrange, Fill bed and Clone; and instances
left out of the print. `test_object_structure.py` checks what objects are made of and how the list orders them:
renaming and deleting, Split and Assemble, parts of every type, Change Type, Order By and an order given, Fix Model,
Reload from disk, Replace 3D file and the keep_painting preference. Both read every object back from `object_list`
after each step, through the readers in `checks.py`.
`tests/scene.json` checks object structure and placement: `object_transform` on an instance (the drop after a
scale, `size`, a move to another plate), on a part, what `object_list` reports of them (bounding boxes
on the bed, filament, the scaled volume, a mirrored part and instance), the selection as `object_select` and
`app_state` report it (parts, whole instances, one instance of two), shapes given a size
(`object_add_primitive {shape, size}`), `object_arrange` on one plate and every plate, Fill bed, the Speed
Dial no-op that `action_run` reports as an error, `part_add` (shapes at a size and a position, a model
file, one undo step, and what it refuses), and the object structure commands (Change Type, Rename,
number of instances, individual objects, Assemble, Order By and its reversal, and what each refuses). It
ends with all of them on one scene: a block with a magnet pocket and a boss, sized, moved to a second
plate, copied six times and arranged there, split into objects, one mirrored, two assembled, ordered,
the plate filled and sliced.
`test_slice_preview.py` checks slicing and what a slice leaves: what `plate_slice` and the Slice and Preview and
Slice All Plates actions slice (no objects, a plate that fails validation, two plates); the statistics of a slice in
one colour and in two; the Preview's tables, legend and layers as `plate_slice_stats`, `view_set`, the Go to layer
action and `app_state` give them, and a G-code file opened for viewing; height range modifiers, variable layer
heights and a plate's layer G-codes, each read in the G-code and kept by a 3MF; every command that takes a plate
index; `view_set`'s display switches, sidebar, legend and G-code window; and `app_state`'s account, network plug-in
and configuration folder. It slices about thirty times.
`tests/layers.json` checks height range modifiers: `object_set_height_ranges` with ranges given out of order
and their settings set with `settings_set` (target `height_range`), their read-back in `object_list`, one
undo step each (and none for the same ranges again, which keep their settings), the layer count of a slice
with them, the refusals (an overlap, a layer height beyond the printer's, a missing filament, an object
setting, an empty range), a range in the second filament, a 3MF round trip, and `[]`. Then
variable layer height profiles on a Benchy with `object_set_variable_layer_height`: Adaptive called from the
Preview tab, its quality's effect on the point count, the layer count of a slice with it, Smooth as one
undo step, Reset and a Reset that changes nothing, the refusals (an argument of another action, the
assemble view), Smooth and Adaptive over height ranges, and a 3MF round trip. Last, layer G-codes on a
cube with `plate_set_custom_gcode`: refused before a slice, a pause by layer and custom G-code by height called
from Prepare (it shows the Preview), the same code again changing nothing, a removal and an in-place
custom edit in one call, the refusals (a layer above the top, a code where another is, nothing to remove,
a missing filament, a missing plate, a plate changed since its slice that the Preview does not show), a
filament change, a 3MF round trip, and `clear`.
`tests/settings_targets.json` checks `settings_list` (each type whole, a saved preset's and a slot's values,
what an object and a region take) and the settings tools' targets on a cube with a modifier and two height
ranges: a value set on the object, the modifier and a range, each read back by index and from the selection
with the value it prints with and where that comes from, and ranges replaced keeping the settings of the one
that stays. `tests/view_switches.json` checks `view_set`'s sidebar, legend, G-code window, section view and
display switches, each set and read back from its reply and `app_state`; a cube placed in the middle of a
plate from `plate_list`'s origin and size; and `app_state`'s account, network plug-in and configuration folder.
`test_settings.py` checks `settings_list` (each type whole, a saved preset's and a slot's values, what an object and
a region take) and the settings commands' targets: a value set on an object, a part, a modifier and a height range,
by index and from the selection, read back with the value it prints with and where that comes from, shown to reach
the print, and ranges replaced keeping the settings of the one that stays.
`test_sidebar_floating.py` launches its own app twice, the second time with the sidebar floating in the saved window
layout, and checks that `view_set`'s `sidebar_width` is refused there.
`tests/recording.json` records while it drives the GUI: clicks on the 3D view, a setting typed, the
Preferences dialog opened and closed, a slice. It stops the recording (frames, length, size) and encodes
it to H.265, then has a nested replay start a recording of the 3D view that it never stops, checks the
replay's end closed it, and encodes that to H.264. Short recordings check that a recording has no overlays
unless `captions` or `pointer` turns one on, that one started with a path and no `max_seconds` runs under an
hour's limit, and that one started with `encode` is encoded as a job once `recording_stop` reports it, the
encode deleting its `.mkv` unless `keep_raw_video_file` keeps it. Its
`project_new` and `recording_stop` calls pass `silent: true`: with no arguments they would do what a
person's pick does, asking and stopping without a report. The encodes need an ffmpeg with libx265 and libx264
(`ORCA_FFMPEG`, or `ffmpeg` on `PATH`) and are optional without one. Look at the videos, or at frames
`ffmpeg -i session.mkv -vf fps=1 frame%02d.png` extracts, for the caption, the pointer and the dialog.
`test_recording.py` records while it drives the GUI (clicks on the 3D view, a setting typed, the Preferences dialog
opened and closed, a slice) and reads the recording back from its file. A nested replay starts a recording it never
stops, which the replay's end closes. Short recordings check that a recording has no overlays unless `captions` or
`pointer` turns one on, that one started with a path and no `max_seconds` runs under an hour's limit, and that one
started with `encode` is encoded as a job once `recording_stop` reports it, the encode deleting its `.mkv` unless
`keep_raw_video_file` keeps it. The encodes need an ffmpeg with libx265 and libx264 (`ORCA_FFMPEG`, or `ffmpeg` on
`PATH`); the checks that need one are skipped without it. The recordings are kept in `--out` (a new temporary
folder without it): look at the videos, or at frames `ffmpeg -i session.mkv -vf fps=1 frame%02d.png` extracts, for
the caption, the pointer and the dialog.
`tests/multicolor.json` assigns filaments to objects and parts through `settings_set`'s object and
part targets, with undo and redo, and reads them back with `settings_get`'s effective values. It then
sets the project's slot colours, flushing multiplier, one flushing volume and plate type through
`project_set_settings` (in one call, the colour first), checks the refusals that leave everything as it was
(the read-only `filament_is_mixed`, a bad colour, a purge mode the printer has no button for, a non-zero
diagonal, a tower off the plate), and moves the prime tower with an undo, before slicing.
`test_filaments.py` assigns filament presets to slots through each route a person or a plugin has: a pick in the
sidebar's selector, its value set with `widget_set_value`, `preset_select` and the plugin API. On one slot it answers
the filament tab's unsaved-changes prompt every way; on three it checks what the Auto-flush preference does to the
flushing volumes when a slot's preset or colour changes. Then it assigns filaments to objects and parts with
`settings_set` and sets the project's slot colours, flushing volumes, plate type and prime tower with
`project_set_settings`, and checks what reaches the print and what the project file keeps.
`tests/presets.json` saves filament, process and printer presets with `preset_save` (a user preset,
one inside the project that a saved and reopened project keeps, a detached one, and the overwrite
rule), and drops unsaved edits with `settings_set {"reset_all": true}`. It selects a filament the selector
does not offer, one the setup wizard has not installed, by name. It reads presets that are not selected and
compares presets (`settings_get` `preset` and `compare`), writes one entry of a
per-variant value, and checks `settings_set`'s `changed` after the spiral vase dialog. It reads what
settings do from their meta (`description`, `where`): by key with `settings_get`, for one group with
`settings_list`, and found by the words of their descriptions, in one type and in all three. Keys named
without a type are read from the type that has each one, and a key named in the wrong type is listed with
the type that has it (`type_of`) and refused by `settings_set`. It reverts single keys (`null`, `reset_to`),
and answers the unsaved-changes prompts:
`preset_select` without `preset_changes` still opens the prompt, `preset_changes` transfers or discards without it,
and `project_new` keeps modified presets unless `preset_changes` is `"discard"`. It ends by deleting the
presets it made with `preset_delete`: filaments the tab edits and does not, a base process and its
child, and a printer once selected, with the refusals for system presets, a preset another inherits
from, unsaved changes and a printer that is not selected. It exports a filament with the Export
Preset Bundle dialog to its `out_dir` (`preset_export` with a directory), imports the archive again
with `preset_import` and a path (kept while the preset exists, imported once it is deleted) and
imports `tests/fixtures/mcp_import_pla.json`. It changes a preference in the Preferences dialog
opened with `window_open {"window": "preferences", "tab": "behaviour", "key": "auto_arrange"}`, by the
control's name, and reads it back with `preferences_get`. It starts from the harness's default printer with one
filament slot in Simple mode, deleting slots and selecting the mode first, and reruns on the same
datadir.
`test_presets.py` checks the presets of the three types: selecting one by the name its selector shows, hidden ones
included; `preset_list`'s filters; what a setting is and where it lives (`settings_get`, `settings_list`); saving,
overwriting, reverting and deleting presets; the unsaved-changes prompt of a preset switch and of a new project,
answered ahead with `preset_changes` or in the dialog; the same selections through the plugin API; a preset kept
inside the project; the Export Preset Bundle dialog and `preset_import` (with `tests/fixtures/mcp_import_pla.json`);
a printer variant picked by its nozzle; a preference changed in the Preferences dialog; and that the presets
selected are what the G-code is sliced with. It needs a freshly launched app on a fresh data folder: a hidden preset
that `preset_select` shows stays shown until a restart.
`test_plates.py` checks the plates of the Prepare view: plates added, duplicated, named, locked, selected and
deleted by index and on the current plate, with undo; what a lock keeps Arrange and Auto-Orient from doing; a
@@ -331,37 +301,21 @@ plate's own settings through `plate_set_settings`; the filament slots its filame
icons and the plate menu. After every step it reads the plates back with `plate_list` and compares them whole with
the state its entry in `test-entries/plates.md` writes out.
`tests/calibration.json` makes every calibration test with `calibration_generate_test` (each pressure advance method,
a 2 x 2 pattern batch, the four flow ratio passes) and checks the objects it added, the parameters
it used and the presets it changed, slicing some of them. It checks the temperature rounding, the
refusals that leave the project as it was (modified presets without `preset_changes`, an argument the test
does not take), `preset_changes: "keep"` keeping an edit, and `project_new` dropping the test's settings. It
starts from the harness's default printer and reruns on the same datadir.
`test_calibration.py` makes every calibration test with `calibration_generate_test` and checks the project it makes,
the parameters it uses, the presets and objects it changes, the warnings for values it rounds, and the refusals that
leave the project and presets as they were; `preset_changes` "keep" and "discard"; and, in the exported G-code, that
the temperature, pressure advance and retraction towers change their value band by band.
`tests/ops_open_project.json`, `ops_select_preset.json`, `ops_assign_filament_preset_one_slot.json` and
`ops_assign_filament_preset_multi_slot.json` drive an operation of the operations layer (`docs/HLSD/mcp-server.md`,
"The operations layer") through the routes that reach it: the command, a Speed Dial action run with `action_run`
where one runs it from a call, and, for presets, a pick in the sidebar and the plugin API called from a
`script_run` step. They open a project, select a printer or process preset, and assign a filament to a slot on a
printer with one slot and with several. Each records what a call leaves: its reply or its refusal's text, the
state read back after it, and the undo snapshots it took, which `tests/fixtures/ops_undo.py` reads from the app's
log since no tool lists the undo history. Their `expect`s are on the setup and on what is read back. A replay
cannot assert a refusal's text, so a call that a route refuses is `optional`, and `result.json` is the record of
those texts.
The preset replays share `tests/fixtures/ops_presets.py`, which sets the slots, colours and flushing
volumes to known values before each case, and each needs a freshly launched app, since a hidden
preset that `preset_select` shows stays shown until a restart. Launch the app from a folder that
holds no `.py` files, since the app's working directory is on Python's module path and a file there can
shadow a standard module that `script_run` needs.
`test_operation_routes.py` asserts what those replays only record: that a command, a Speed Dial action that
runs it and the plugin API's binding refuse the same states with the same code and words, and accept the
`test_operation_routes.py` drives an operation of the operations layer (`docs/HLSD/mcp-server.md`, "The operations
layer") through the routes that reach it, and checks that a command, a Speed Dial action that runs it and the plugin
API's binding refuse the same states with the same code and words, and accept the
same ones: a layer asked of a Preview with none (the Go to layer action and `view_set`), a mixed-colour
filament slot, and a hidden printer selected through the plugin API. It also checks what a command refuses
or does in those states alone: a project saved under a `.gcode.3mf` name, the exports of a project with no
objects, and an arrangement from the assemble view and with a gizmo open. Run
it on a freshly launched app, for the reasons above and because the Preview keeps the last slice's
layers.
objects, and an arrangement from the assemble view and with a gizmo open. Run it on a freshly launched app,
since a hidden preset that `preset_select` shows stays shown until a restart, and launch the app from a folder
that holds no `.py` files, since the app's working directory is on Python's module path and a file there can
shadow a standard module that `script_run` needs.
The Design-tab replays drive the Design commands through `tool_call` and need an instance launched with
`--cad`. Each starts from a new project and checks what it builds by volume and by what the reading
@@ -478,20 +432,13 @@ answers in `<datadir>/log/debug_*.log.0`, with the reason when it cancels one a
input reaches the app through wxWidgets, not the OS, so a focus problem that only a window manager
causes is out of the tests' reach.
`tests/dialogs_canvas_input.json` checks that an auto-answered Transfer or Discard on the
unsaved-changes dialog does its work, that a toolbar item a selection just enabled takes a click at
once, and that a negative part, and a point seen through the bed from below, are click targets.
`tests/context_menus.json` right-clicks a cube, the empty bed and two selected objects, and clicks a
preset edit button that opens a menu: each menu is listed in the reply, or an item of it run with
`popup_item` (a modifier, a primitive, Delete), and none is ever shown, so on macOS the run finishes
with nobody pressing Escape. It also picks the Edit menu's Undo and Redo by the paths `Edit>Undo` and
`Edit>Redo`, which name them on every platform, though macOS shows their keys after them.
`tests/rows.json` drives rows and popups: object list rows (plates, an object and its parts, Ctrl
to add a row, the Printable column, a double click), the object's and a part's menus run from their
rows, Compare presets' rows, the object settings table, the print button's popup and the plate type
drop-down list. On Linux run it with `--headless`: under Xvfb those popups close as soon as they open.
`test_gui_tools.py` drives the generic GUI tools on the app's own widgets: context menus and a button's menu listed
in the reply, or an item of them run with `popup_item`, none ever shown, so on macOS the run finishes with nobody
pressing Escape; the Edit menu's Undo and Redo by the paths `Edit>Undo` and `Edit>Redo`, which name them on every
platform; the rows of the object list, Compare presets and the parameter table; the print button's popup and a
drop-down list; and Orca's web dialogs. Each item, row or page element it runs is checked by what it does to the
project, the selection, the camera or the settings. On Linux run it with `--headless`: under Xvfb those popups close
as soon as they open.
`test_webview_modal.py` runs JavaScript in the web views of modal dialogs: the preset bundle dialog's
page takes it by default and by locator, `webview_run_javascript` is refused in the Home tab's web view behind a
@@ -500,7 +447,7 @@ dialog's does, and a page that closes its dialog replies `closed` at once.
Web pages are driven like widgets: `widget_list` lists each shown page's elements under its web view
with `d` refs, and `widget_click`, `widget_set_value`, `keyboard_press`, `mouse_gesture` and `dialog_answer` act on them, by
ref or by `{web: "Next", kind, css, within, index}`. `tests/web_dialogs.json` drives Orca's own web
ref or by `{web: "Next", kind, css, within, index}`. `test_gui_tools.py` drives Orca's own web
dialogs that way alone: the preset bundle dialog, the colour picker behind a filament swatch (its hex
field, and a drag on its spectrum) and the setup wizard's first steps. `test_web_ui.py` covers every
kind of page control, action and what it changed on its page, refusal, locator, timeout and close on
@@ -542,31 +489,22 @@ proved only where no pointer rests on the view: on a native Wayland display, or
elsewhere. Where KWin runs the display, it also checks through KWin's D-Bus that KWin draws no title bar on
the dial.
`tests/slice_stats.json` slices one cube, then two cubes in two colours, and checks the statistics of
`plate_slice`'s reply: layers, max Z, filament changes, and each filament slot's model, flush and
prime tower grams.
`tests/preview.json` slices a cube and reads it back with `plate_slice_stats` (summary, feature and layer
tables, the object, the legend's state and colour ranges) and `app_state.preview` as `view_set`
changes the layer (by number and by height), the view type, legend rows and time estimate, then
reads the cube's G-code opened for viewing the same way. Run it on a fresh datadir: modified presets
left by an earlier replay make opening the G-code ask about them. `test_set_view_preview.py` checks
what that replay cannot: `view_set {view_type}` acts as the legend's combo (a feature type hidden by
a click on its row shows again on Line Type, and the pick reaches the app config), a canvas
screenshot straight after a layer or view type change shows the new layers and the legend laid out
(it matches the capture after it), and the refusals of the preview arguments.
`test_set_view_preview.py` checks that `view_set {view_type}` acts as the legend's combo (a feature type hidden by a
click on its row shows again on Line Type, and the pick reaches the app config), that a canvas screenshot straight
after a layer or view type change shows the new layers and the legend laid out (it matches the capture after it),
and the refusals of the preview arguments.
`test_set_view_camera.py`, on an instance launched with `--cad`, checks `view_set`'s `look_at` and `zoom`
on Prepare, Preview and the Design tab, and `orbit` on Prepare and the Design tab, against the reply's
`camera_state` and `app_state.camera`, including straight after `project_new`, whose fit runs at the
next frame, and a fit on Prepare after the window was sized on the Home tab.
`tests/agent_forms.json` calls commands the way agents often write them: a lone path for `paths`,
`object` for `objects` with the index as a string, an action by the key inside its id, `action` for
`id`, a camera direction as `view_set`'s `canvas`, which is read as its `camera`, `object_transform` to a
`position`, `key` for `keys`, `app_wait` with no condition, a gizmo by its toolbar title, `plate` for
`plates`, legend rows in another case or with `_` for a space, and `project_export` with the format taken
from the path. It also checks that a type's whole `settings_list` listing leaves meta out.
`test_call_forms.py`, on an instance launched with `--cad`, calls commands the way agents often write them: a lone
path for `paths`, `object` for `objects` with the index as a string, an action by its short name, `action` for
`id`, a camera direction as `view_set`'s `canvas`, which is read as its `camera`, `key` for `keys`, `app_wait` with
no condition, a gizmo by its toolbar title, `plate` as a string, legend rows in another case or with `_` for a space,
and `project_export` with the format taken from the path, each shown by what the call did. It also checks that a
type's whole `settings_list` listing leaves meta out.
`test_stdio_bridge.py [--bin PATH]` checks `orca-slicer --mcp-stdio` against the launched instance:
the handshake, notifications, tool calls in both protocol eras, and errors. With no instance
@@ -594,11 +532,11 @@ reads uploading at 99 until the stub answers and then completed in `app_state.up
replay uploads again, and one the stub refuses with HTTP 500 never reads completed and ends as an
error whose dialog `dialog_answer` closes.
`tests/actions_ask.json` and `test_person_forms.py` check a call with exactly an action's arguments, which may
ask as a person's pick of the action does: `calibration_generate_test {test}` asks in the test's dialog and with
`silent` runs with its defaults, View: Top turns the Design tab's camera, Go to tab and Go to layer take their
value through `action_run`, and the slice actions slice and show the Preview tab (the replay, on an instance
launched with `--cad`); `project_save {save_as: true}` and `project_export {format: gcode}` open their file
`test_call_forms.py` and `test_person_forms.py` check a call with exactly an action's arguments, which may ask
as a person's pick of the action does: `calibration_generate_test {test}` asks in the test's dialog and with
`silent` runs with its defaults, View: Top turns the camera of the view shown, Deselect All closes the open gizmo
too, Go to layer takes its value through `action_run`, and `plate_slice {preview: true}` slices and shows the
Preview tab (`test_call_forms.py`); `project_save {save_as: true}` and `project_export {format: gcode}` open their file
pickers while a path writes without one, `preset_export` always opens its dialog, `object_arrange {}` and
`object_select {all: true}` (and `action_run` of their actions) reply as their commands do, the selection in the
assemble view's too, and the Speed Dial's own picks of a view action, Deselect All, Go to layer, Auto-Arrange and
@@ -606,21 +544,12 @@ Select All Objects run in place (the script). `test_project_open_settings.py`
launches its own app, whose Preferences load a project's geometry only, and checks that `project_open` loads
the settings a project was saved with all the same.
The commands that do a menu item's job take their targets by index, and the replays call them so and read each
back: `tests/menu_items_objects.json` (rename, instances, separate, delete, height ranges),
`menu_items_structure.json` (split, assemble, change type, order) and `menu_items_placement.json` (add a
primitive by numbers, mirror, drop, centre, scale to fit, auto-orient), and `test_plates.py` the plate ones;
`objects_state.json` (`object_set_printable`, `object_fix`, `object_set_auto_drop`), `objects_files.json`
(`object_clone`, `object_reload_from_disk`, `part_replace`, with the files `tests/fixtures/objects_files.py`
writes), `objects_order.json` (`object_order {order}`), `filaments_and_files.json` (a slot merged into
another, a mixed filament, exports of some objects and of each object, a ZIP's entries, a STEP file),
`settings_targets.json` (`settings_list`, and the settings commands' targets object, part and height range),
`presets_and_plate_map.json` (`preset_list`'s filters, a plate's filament map, a nozzle variant) and
`view_switches.json` (`view_set`'s display switches, sidebar and legend, and an object placed by a plate's
`origin` and `size`). A replay cannot expect an error, so the refusals are Python tests:
`test_menu_items_refusals.py` checks that each object command made from menu items refuses with its own
reason, and `test_additions_refusals.py` the filament, preset, export and import commands'.
`test_preferences.py` checks
The commands that do a menu item's job take their targets by index, and `test_objects.py`,
`test_object_structure.py` and `test_plates.py` call them so and read each back. `test_menu_items_refusals.py`
checks that each object command made from menu items refuses with its own reason, and `test_additions_refusals.py`
the filament, preset, export and import commands'. `test_files.py` checks the project's files: a new project and its
question, opening, saving, importing models, every export read back from its file, and the filament slots a merge
and a mix leave in the project file. `test_preferences.py` checks
`preferences_get` and `preferences_set` against the Preferences dialog, tab by tab. Some launch their own app,
on a fresh data folder and printers the sweep does not seed: `test_install_printers.py` and
`test_install_filaments.py` (installs and uninstalls, read back after a restart), `test_plugin_commands.py`
@@ -643,7 +572,8 @@ and defaults to half the cores, up to six. It exits 0 when all of them pass and
report appeared (macOS). `sweep.json` lists each test
with what it needs, and a test file it does not list stops the run before anything starts, so a new
test is never skipped by accident. Each test runs in a folder of its own under `--out` (by default a
new `orca-sweep-<time>` folder in the temporary folder), with its own datadir, port (from 14100 up),
new `orca-sweep-<time>` folder in the temporary folder), with its own datadir, port (from 14100 up, or from
`--first-port`, so that two sweeps can run side by side),
session file (`ORCA_MCP_SESSION`), temporary folder (`TMPDIR`, `TMP`, `TEMP`) and empty working
folder, and leaves `test.log` there and `results.jsonl` beside them. The longest tests start first,
by each one's last passing time in `--history` (`~/.cache/orca-mcp/sweep-times.json`). Tests that
+38 -73
View File
@@ -112,13 +112,13 @@ until they leave the sweep.
| Area | Python tests | Replays still in the sweep |
|---|---|---|
| [Plates](test-entries/plates.md) | [`test_plates`](test-entries/plates.md#test_plates) | — |
| [Objects](test-entries/objects.md) | [`test_objects`](test-entries/objects.md#test_objects), [`test_object_structure`](test-entries/objects.md#test_object_structure) | [`menu_items_objects`](test-entries/objects.md#menu_items_objects), [`menu_items_placement`](test-entries/objects.md#menu_items_placement), [`menu_items_structure`](test-entries/objects.md#menu_items_structure), [`objects_state`](test-entries/objects.md#objects_state), [`objects_order`](test-entries/objects.md#objects_order), [`objects_files`](test-entries/objects.md#objects_files), [`scene`](test-entries/objects.md#scene) |
| [Presets and calibration](test-entries/presets.md) | [`test_presets`](test-entries/presets.md#test_presets), [`test_calibration`](test-entries/presets.md#test_calibration) | [`presets`](test-entries/presets.md#presets), [`presets_and_plate_map`](test-entries/presets.md#presets_and_plate_map), [`ops_select_preset`](test-entries/presets.md#ops_select_preset), [`calibration`](test-entries/presets.md#calibration) |
| [Filaments and settings](test-entries/filaments_settings.md) | [`test_filaments`](test-entries/filaments_settings.md#test_filaments), [`test_settings`](test-entries/filaments_settings.md#test_settings) | [`ops_assign_filament_preset_one_slot`](test-entries/filaments_settings.md#ops_assign_filament_preset_one_slot), [`ops_assign_filament_preset_multi_slot`](test-entries/filaments_settings.md#ops_assign_filament_preset_multi_slot), [`multicolor`](test-entries/filaments_settings.md#multicolor), [`settings_targets`](test-entries/filaments_settings.md#settings_targets) |
| [Project files, imports and exports](test-entries/files.md) | [`test_files`](test-entries/files.md#test_files) | [`filaments_and_files`](test-entries/files.md#filaments_and_files), [`new_project_keeps_layer_gcode`](test-entries/files.md#new_project_keeps_layer_gcode), [`ops_open_project`](test-entries/files.md#ops_open_project) |
| [Slicing, layers and the Preview](test-entries/slice_preview.md) | [`test_slice_preview`](test-entries/slice_preview.md#test_slice_preview) | [`slice_stats`](test-entries/slice_preview.md#slice_stats), [`preview`](test-entries/slice_preview.md#preview), [`layers`](test-entries/slice_preview.md#layers), [`view_switches`](test-entries/slice_preview.md#view_switches) |
| [Gizmos and canvas input](test-entries/gizmos.md) | [`test_gizmos`](test-entries/gizmos.md#test_gizmos) | [`gizmos`](test-entries/gizmos.md#gizmos), [`dialogs_canvas_input`](test-entries/gizmos.md#dialogs_canvas_input) |
| [GUI automation tools](test-entries/gui_tools.md) | [`test_gui_tools`](test-entries/gui_tools.md#test_gui_tools), [`test_recording`](test-entries/gui_tools.md#test_recording), [`test_call_forms`](test-entries/gui_tools.md#test_call_forms) | [`context_menus`](test-entries/gui_tools.md#context_menus), [`rows`](test-entries/gui_tools.md#rows), [`web_dialogs`](test-entries/gui_tools.md#web_dialogs), [`recording`](test-entries/gui_tools.md#recording), [`agent_forms`](test-entries/gui_tools.md#agent_forms), [`actions_ask`](test-entries/gui_tools.md#actions_ask) |
| [Objects](test-entries/objects.md) | [`test_objects`](test-entries/objects.md#test_objects), [`test_object_structure`](test-entries/objects.md#test_object_structure) | — |
| [Presets and calibration](test-entries/presets.md) | [`test_presets`](test-entries/presets.md#test_presets), [`test_calibration`](test-entries/presets.md#test_calibration) | — |
| [Filaments and settings](test-entries/filaments_settings.md) | [`test_filaments`](test-entries/filaments_settings.md#test_filaments), [`test_settings`](test-entries/filaments_settings.md#test_settings) | — |
| [Project files, imports and exports](test-entries/files.md) | [`test_files`](test-entries/files.md#test_files) | — |
| [Slicing, layers and the Preview](test-entries/slice_preview.md) | [`test_slice_preview`](test-entries/slice_preview.md#test_slice_preview) | — |
| [Gizmos and canvas input](test-entries/gizmos.md) | [`test_gizmos`](test-entries/gizmos.md#test_gizmos) | — |
| [GUI automation tools](test-entries/gui_tools.md) | [`test_gui_tools`](test-entries/gui_tools.md#test_gui_tools), [`test_recording`](test-entries/gui_tools.md#test_recording), [`test_call_forms`](test-entries/gui_tools.md#test_call_forms) | — |
| [Commands, preferences, installs and plugins](test-entries/commands.md) | [`test_every_action`](test-entries/commands.md#test_every_action), [`test_menu_items_refusals`](test-entries/commands.md#test_menu_items_refusals), [`test_additions_refusals`](test-entries/commands.md#test_additions_refusals), [`test_person_forms`](test-entries/commands.md#test_person_forms), [`test_preferences`](test-entries/commands.md#test_preferences), [`test_install_printers`](test-entries/commands.md#test_install_printers), [`test_install_filaments`](test-entries/commands.md#test_install_filaments), [`test_plugin_commands`](test-entries/commands.md#test_plugin_commands), [`test_plugin_tools`](test-entries/commands.md#test_plugin_tools), [`test_operation_routes`](test-entries/commands.md#test_operation_routes) | — |
| [Windows, views, printers and web pages](test-entries/windows_web.md) | [`test_printer_extruders`](test-entries/windows_web.md#test_printer_extruders), [`test_project_open_settings`](test-entries/windows_web.md#test_project_open_settings), [`test_sidebar_floating`](test-entries/windows_web.md#test_sidebar_floating), [`test_set_window`](test-entries/windows_web.md#test_set_window), [`test_set_view_preview`](test-entries/windows_web.md#test_set_view_preview), [`test_set_view_camera`](test-entries/windows_web.md#test_set_view_camera), [`test_speed_dial_open`](test-entries/windows_web.md#test_speed_dial_open), [`test_send_gcode`](test-entries/windows_web.md#test_send_gcode), [`test_web_ui`](test-entries/windows_web.md#test_web_ui), [`test_webview_modal`](test-entries/windows_web.md#test_webview_modal) | — |
| [Runtime, command line and harness](test-entries/runtime.md) | [`test_command_line`](test-entries/runtime.md#test_command_line), [`test_runtime_lifecycle`](test-entries/runtime.md#test_runtime_lifecycle), [`test_stdio_bridge`](test-entries/runtime.md#test_stdio_bridge), [`test_orca_mcp_attach`](test-entries/runtime.md#test_orca_mcp_attach), [`test_run_sweep`](test-entries/runtime.md#test_run_sweep), [`test_recovery_under_load`](test-entries/runtime.md#test_recovery_under_load), [`test_worker_admission`](test-entries/runtime.md#test_worker_admission), [`test_cancel_pending_slice`](test-entries/runtime.md#test_cancel_pending_slice), [`test_export_running_job`](test-entries/runtime.md#test_export_running_job), [`test_action_replay_hidden`](test-entries/runtime.md#test_action_replay_hidden), [`test_list_windows`](test-entries/runtime.md#test_list_windows), [`test_ref_locator_export`](test-entries/runtime.md#test_ref_locator_export) | [`smoke_test`](test-entries/runtime.md#smoke_test) |
@@ -126,41 +126,23 @@ until they leave the sweep.
## All tests
The 78 tests `sweep.json` lists: 46 Strong, 27 Partial, 5 Smoke.
The 60 tests `sweep.json` lists: 44 Strong, 14 Partial, 2 Smoke.
| Test | Area | Kind | Strength |
|---|---|---|---|
| [`test_plates`](test-entries/plates.md#test_plates) | [Plates](test-entries/plates.md) | Python | Strong |
| [`menu_items_objects`](test-entries/objects.md#menu_items_objects) | [Objects](test-entries/objects.md) | replay | Strong |
| [`menu_items_placement`](test-entries/objects.md#menu_items_placement) | [Objects](test-entries/objects.md) | replay | Strong |
| [`menu_items_structure`](test-entries/objects.md#menu_items_structure) | [Objects](test-entries/objects.md) | replay | Strong |
| [`objects_state`](test-entries/objects.md#objects_state) | [Objects](test-entries/objects.md) | replay | Strong |
| [`objects_order`](test-entries/objects.md#objects_order) | [Objects](test-entries/objects.md) | replay | Strong |
| [`objects_files`](test-entries/objects.md#objects_files) | [Objects](test-entries/objects.md) | replay | Partial |
| [`scene`](test-entries/objects.md#scene) | [Objects](test-entries/objects.md) | replay | Partial |
| [`presets`](test-entries/presets.md#presets) | [Presets and calibration](test-entries/presets.md) | replay | Strong |
| [`presets_and_plate_map`](test-entries/presets.md#presets_and_plate_map) | [Presets and calibration](test-entries/presets.md) | replay | Strong |
| [`ops_select_preset`](test-entries/presets.md#ops_select_preset) | [Presets and calibration](test-entries/presets.md) | replay | Smoke |
| [`calibration`](test-entries/presets.md#calibration) | [Presets and calibration](test-entries/presets.md) | replay | Strong |
| [`ops_assign_filament_preset_one_slot`](test-entries/filaments_settings.md#ops_assign_filament_preset_one_slot) | [Filaments and settings](test-entries/filaments_settings.md) | replay | Smoke |
| [`ops_assign_filament_preset_multi_slot`](test-entries/filaments_settings.md#ops_assign_filament_preset_multi_slot) | [Filaments and settings](test-entries/filaments_settings.md) | replay | Smoke |
| [`multicolor`](test-entries/filaments_settings.md#multicolor) | [Filaments and settings](test-entries/filaments_settings.md) | replay | Partial |
| [`settings_targets`](test-entries/filaments_settings.md#settings_targets) | [Filaments and settings](test-entries/filaments_settings.md) | replay | Strong |
| [`filaments_and_files`](test-entries/files.md#filaments_and_files) | [Project files, imports and exports](test-entries/files.md) | replay | Partial |
| [`new_project_keeps_layer_gcode`](test-entries/files.md#new_project_keeps_layer_gcode) | [Project files, imports and exports](test-entries/files.md) | replay | Partial |
| [`ops_open_project`](test-entries/files.md#ops_open_project) | [Project files, imports and exports](test-entries/files.md) | replay | Partial |
| [`slice_stats`](test-entries/slice_preview.md#slice_stats) | [Slicing, layers and the Preview](test-entries/slice_preview.md) | replay | Strong |
| [`preview`](test-entries/slice_preview.md#preview) | [Slicing, layers and the Preview](test-entries/slice_preview.md) | replay | Strong |
| [`layers`](test-entries/slice_preview.md#layers) | [Slicing, layers and the Preview](test-entries/slice_preview.md) | replay | Strong |
| [`view_switches`](test-entries/slice_preview.md#view_switches) | [Slicing, layers and the Preview](test-entries/slice_preview.md) | replay | Strong |
| [`gizmos`](test-entries/gizmos.md#gizmos) | [Gizmos and canvas input](test-entries/gizmos.md) | replay | Partial |
| [`dialogs_canvas_input`](test-entries/gizmos.md#dialogs_canvas_input) | [Gizmos and canvas input](test-entries/gizmos.md) | replay | Partial |
| [`context_menus`](test-entries/gui_tools.md#context_menus) | [GUI automation tools](test-entries/gui_tools.md) | replay | Strong |
| [`rows`](test-entries/gui_tools.md#rows) | [GUI automation tools](test-entries/gui_tools.md) | replay | Partial |
| [`web_dialogs`](test-entries/gui_tools.md#web_dialogs) | [GUI automation tools](test-entries/gui_tools.md) | replay | Partial |
| [`recording`](test-entries/gui_tools.md#recording) | [GUI automation tools](test-entries/gui_tools.md) | replay | Partial |
| [`agent_forms`](test-entries/gui_tools.md#agent_forms) | [GUI automation tools](test-entries/gui_tools.md) | replay | Partial |
| [`actions_ask`](test-entries/gui_tools.md#actions_ask) | [GUI automation tools](test-entries/gui_tools.md) | replay | Partial |
| [`test_objects`](test-entries/objects.md#test_objects) | [Objects](test-entries/objects.md) | Python | Strong |
| [`test_object_structure`](test-entries/objects.md#test_object_structure) | [Objects](test-entries/objects.md) | Python | Strong |
| [`test_presets`](test-entries/presets.md#test_presets) | [Presets and calibration](test-entries/presets.md) | Python | Strong |
| [`test_calibration`](test-entries/presets.md#test_calibration) | [Presets and calibration](test-entries/presets.md) | Python | Strong |
| [`test_filaments`](test-entries/filaments_settings.md#test_filaments) | [Filaments and settings](test-entries/filaments_settings.md) | Python | Strong |
| [`test_settings`](test-entries/filaments_settings.md#test_settings) | [Filaments and settings](test-entries/filaments_settings.md) | Python | Strong |
| [`test_files`](test-entries/files.md#test_files) | [Project files, imports and exports](test-entries/files.md) | Python | Strong |
| [`test_slice_preview`](test-entries/slice_preview.md#test_slice_preview) | [Slicing, layers and the Preview](test-entries/slice_preview.md) | Python | Strong |
| [`test_gizmos`](test-entries/gizmos.md#test_gizmos) | [Gizmos and canvas input](test-entries/gizmos.md) | Python | Strong |
| [`test_gui_tools`](test-entries/gui_tools.md#test_gui_tools) | [GUI automation tools](test-entries/gui_tools.md) | Python | Strong |
| [`test_recording`](test-entries/gui_tools.md#test_recording) | [GUI automation tools](test-entries/gui_tools.md) | Python | Strong |
| [`test_call_forms`](test-entries/gui_tools.md#test_call_forms) | [GUI automation tools](test-entries/gui_tools.md) | Python | Strong |
| [`test_every_action`](test-entries/commands.md#test_every_action) | [Commands, preferences, installs and plugins](test-entries/commands.md) | Python | Partial |
| [`test_menu_items_refusals`](test-entries/commands.md#test_menu_items_refusals) | [Commands, preferences, installs and plugins](test-entries/commands.md) | Python | Strong |
| [`test_additions_refusals`](test-entries/commands.md#test_additions_refusals) | [Commands, preferences, installs and plugins](test-entries/commands.md) | Python | Strong |
@@ -211,42 +193,25 @@ The 78 tests `sweep.json` lists: 46 Strong, 27 Partial, 5 Smoke.
## What the sweep does not catch
These patterns run across many tests, and each lets a real regression pass. The entries in the area files name where
each one applies.
These patterns remain, and each lets a real regression pass. The entries in the area files name where each one
applies.
**The operations replays record and do not check.** In the four `ops_*` replays, the `expect`s sit on the setup,
and the calls under test are `optional`, the ones that should succeed as well as the ones that should be refused.
Their `result.json` is a record, but nothing compares it with an earlier run's. `test_operation_routes` asserts a
handful of the states they record.
**The Design tab's tests are not under the read-back rule.** The `cad_*` replays still in the sweep and the
`test_cad_*.py` tests are as they were. In the replays a step marked `optional` accepts both outcomes, so a step that
should be refused passes when it is accepted and one that should succeed passes when it is refused; a refusal is
caught only when a later step reads the state it would have changed. A replay's `app_wait` that runs out of time
replies `satisfied: false`, or a job still running, as a successful result, so it pauses the replay and checks
nothing.
**`optional` accepts both outcomes.** A step that should be refused passes when it is accepted, and one that
should succeed passes when it is refused. A refusal is caught only when a later step happens to read the state it
would have changed, and many refusals have no such step. The Design replays come closest, since a refused call that
went through would usually shift a feature index or a count that the next step checks.
**What the app works out is held to bounds.** Grams, times, adaptive layer profiles, arrangements, frame counts and
capture times follow the slicer's or the machine's work, so their checks are bounds or properties, and a change that
stays inside them passes.
**A wait that runs out of time passes.** `app_wait` replies `satisfied: false`, or `status: "running"` for a job,
as a successful result when its time runs out. Most `app_wait` steps have no `expect`, including the ones meant to
show that a prompt opened, so they pause the replay for up to 30 s and check nothing.
**Pictures are compared only with each other.** Screenshots and recordings are checked by their size, their source,
or how they differ from another capture of the same run, never against a reference picture, so a view that draws
something wrong passes.
**Fixtures return data and assert nothing.** The `tests/fixtures/*.py` helpers fail their step only when they raise
by accident. `ops_presets.preset_api` catches every exception and returns it as data, so no plugin API call in the
preset replays can fail.
**Replies are trusted instead of read back.** Several checks compare a tool's reply with the arguments it was
given, such as a window's size and position, the legend rows, or a dialog's size. Others pass whenever the call
returns, as `check(name, True)` after the call. Neither reads the state the call should have left.
**Slices are checked by their outcome.** Tests that set per-object, per-range or per-layer settings check that the
slice ended `ok`, and `layers` also checks the layer count. No test reads the G-code, so a setting that never
reaches the print passes.
**Screenshots and recordings are kept, not compared.** Nearly every GUI test saves pictures. Only
`test_set_view_preview` (two captures byte for byte) and `test_cad_commands` ("the screenshots differ") compare any.
**Absence is checked without a control.** Checks such as "no notice", "not in the journal", "the notification gets
no reply", "the broken plugin offers nothing" and a colour's text being absent pass just as well when the thing they
look for was renamed or never produced. No step first shows that it can be seen.
**A few tests wait a fixed time instead of synchronising.** `test_cancel_pending_slice` (0.1 s),
`test_recovery_under_load` (2 s and 1 s) and `test_cad_slow_build` on Windows (2 s) can pass on a slow machine
without reaching the state they claim to test.
**A few steps still trust a fixed time.** `test_cancel_pending_slice` cancels 0.1 s after asking for the slice and
then checks that the cancel came before the slice started, so a slow machine fails it rather than passing it;
`test_recovery_under_load` gives its 32 half-sent connections 1 s to open and trusts that they filled the server's
connections.
+260
View File
@@ -121,3 +121,263 @@ def objects(client):
listing = client.call("object_list", limit=500)
on = sorted((p["index"], o["name"]) for p in listing["plates"] for o in p["objects"])
return on, sorted(o["name"] for o in listing.get("outside", []))
# ---- Objects: the readers of test-entries/objects.md, shared by test_objects and test_object_structure ----
import math # noqa: E402
import re # noqa: E402
def scene(client):
"""Each object of object_list in index order, its entry whole, with its instances gathered from every plate and
from outside, in index order, each given its plate (-1 outside). object_list lists an object under each plate it
has instances on, with that plate's instances alone."""
listing = client.call("object_list", limit=500)
found = {}
groups = [(p["index"], p["objects"]) for p in listing["plates"]] + [(-1, listing.get("outside", []))]
for plate, entries in groups:
for entry in entries:
obj = found.setdefault(entry["index"], {**entry, "instances": []})
obj["instances"] += [{**inst, "plate": plate} for inst in entry["instances"]]
for obj in found.values():
obj["instances"].sort(key=lambda inst: inst["index"])
return [found[i] for i in sorted(found)]
def selection(client):
"""app_state's selection as {objects, instances, parts}, parts absent when whole instances are selected."""
sel = client.call("app_state").get("selection", {})
out = {"objects": sel.get("objects", []), "instances": sel.get("instances", [])}
if "parts" in sel:
out["parts"] = sel["parts"]
return out
def corner(client, plate):
"""Plate `plate`'s front left corner: its origin from plate_list, [x, y]."""
return client.call("plate_list", limit=500)["items"][plate]["origin"]
def rect(client, plate):
"""Plate `plate`'s rectangle (x0, y0, x1, y1), from its origin and size in plate_list."""
item = client.call("plate_list", limit=500)["items"][plate]
(x, y), (w, d) = item["origin"], item["size"]
return x, y, x + w, y + d
PRINTING = re.compile(r"^; printing object (.*) id:(\d+) copy (\d+)\s*$")
def gcode_prints(path):
"""What a G-code file prints, from its `; printing object <name> id:<n> copy <c>` comments: [(name, copies)] in
the order each name first prints, copies being the number of different (id, copy) pairs printed under it."""
printed = {}
with open(path, encoding="utf-8", errors="replace") as f:
for line in f:
m = PRINTING.match(line)
if m:
printed.setdefault(m.group(1), set()).add((m.group(2), m.group(3)))
return [(name, len(pairs)) for name, pairs in printed.items()]
def square(instance):
"""An instance's square: its bbox in x and y, (x0, y0, x1, y1)."""
box = instance["bbox"]
return box["min"][0], box["min"][1], box["max"][0], box["max"][1]
def apart(a, b):
"""Two squares do not overlap (touching edges do not overlap)."""
return a[2] <= b[0] or b[2] <= a[0] or a[3] <= b[1] or b[3] <= a[1]
def inside(sq, rectangle):
"""A square lies within a rectangle (x0, y0, x1, y1), such as rect(p)."""
return sq[0] >= rectangle[0] and sq[1] >= rectangle[1] and sq[2] <= rectangle[2] and sq[3] <= rectangle[3]
def gap(a, b):
"""The distance between two squares: along the axis on which they are apart, corner to corner when they are apart
on both; 0 when they overlap."""
dx = max(b[0] - a[2], a[0] - b[2], 0)
dy = max(b[1] - a[3], a[1] - b[3], 0)
return math.hypot(dx, dy)
# ---- Project files: the readers of test-entries/files.md, for test_files ----
import io # noqa: E402
import os # noqa: E402
import zipfile # noqa: E402
UNDO_LINE = "Undo / Redo snapshot taken: "
RECENT = re.compile(r"^Open the recent project (.*)\.$")
PLATE_GCODE = re.compile(r"^Metadata/plate_\d+\.gcode$")
def normal(path):
"""A path as the project readers compare it: os.path.normcase of os.path.abspath, None for "" (no file)."""
return os.path.normcase(os.path.abspath(path)) if path else None
def project(client):
"""app_state's project as {name, file, dirty}, file being its path normalised by normal()."""
p = client.call("app_state")["project"]
return {"name": p["name"], "file": normal(p["path"]), "dirty": p["dirty"]}
def meshes(client):
"""Each object of object_list, plate by plate and then those outside, as {name, offset, size, filament, parts}:
its first instance's offset x and y, its bbox size, its filament, and each part as {id, type, triangles,
mesh_volume}."""
listing = client.call("object_list", limit=500)
entries = [o for p in listing["plates"] for o in p["objects"]] + listing.get("outside", [])
return [{"name": o["name"], "offset": o["instances"][0]["offset"][:2], "size": o["bbox"]["size"],
"filament": o.get("filament"),
"parts": [{"id": p["id"], "type": p["type"], "triangles": p["triangles"], "mesh_volume": p["mesh_volume"]}
for p in o["parts"]]}
for o in entries]
def values(client, keys, type="process"):
"""The settings `keys` of the preset of `type` being edited, as {key: value}, each value a string as settings_get
gives it."""
reply = client.call("settings_get", type=type, keys=list(keys), include_meta=False)
return {item["key"]: item["value"] for item in reply["items"]}
def unsaved(client, type):
"""The keys, sorted, in which the preset of `type` being edited differs from that preset as it is stored."""
reply = client.call("settings_get", type=type, compare=":saved", limit=500)
return sorted(item["key"] for item in reply["items"])
def recent(client):
"""The files of the Recent Projects actions, normalised by normal(), read from each one's description ("Open the
recent project <path>.")."""
items = client.call("action_search", group="Recent Projects", limit=100)["items"]
return [normal(m.group(1)) for m in (RECENT.match(i.get("description", "")) for i in items) if m]
def undo_steps(client):
"""The names of the undo steps the app logged (its log's lines `Undo / Redo snapshot taken: <name>`) since this
reader's previous call for `client`, or since the app started on the first. A check calls it just before its
step, which sets the mark, and checks what the call after the step gives."""
log = client.call("app_log", lines=1)["file"]
with open(log, encoding="utf-8", errors="replace") as f:
names = [line.split(UNDO_LINE, 1)[1].split(", Undo / Redo stack memory")[0].rstrip("\r\n")
for line in f if UNDO_LINE in line]
file, seen = getattr(client, "undo_mark", (None, 0))
start = seen if file == log and seen <= len(names) else 0
client.undo_mark = (log, len(names))
return names[start:]
def dialogs(client):
"""The open dialogs from app_state, the topmost last, as {title, message}."""
return [{"title": d.get("title"), "message": d.get("message")} for d in client.call("app_state").get("dialogs", [])]
def sliced_flags(client):
"""Whether each plate is sliced, from plate_list, in plate order."""
return [p["sliced"] for p in client.call("plate_list", limit=500)["items"]]
def layer_gcode(client):
"""Plate 0's layer G-code from plate_list, each code as {z, type}."""
return [{"z": g["z"], "type": g["type"]} for g in client.call("plate_list", limit=500)["items"][0]["layer_gcode"]]
def gcode_facts(lines):
"""What G-code text holds: `layers`, the number on its `; total layer number: N` line; `labels`, how many ids its
`; model label id:` line lists; and `config`, the `; key = value` lines of its configuration block as
{key: value}. A line the text lacks gives None."""
layers, labels, config, block = None, None, {}, False
for line in lines:
line = line.rstrip("\r\n")
if layers is None and line.startswith("; total layer number:"):
layers = int(line.split(":", 1)[1])
elif labels is None and line.startswith("; model label id:"):
labels = len([i for i in line.split(":", 1)[1].split(",") if i.strip()])
elif line == "; CONFIG_BLOCK_START":
block = True
elif line == "; CONFIG_BLOCK_END":
block = False
elif block and line.startswith("; ") and " = " in line:
key, _, value = line[2:].partition(" = ")
config[key] = value
return {"layers": layers, "labels": labels, "config": config}
def gcode(path):
"""gcode_facts() of a G-code file."""
with open(path, encoding="utf-8", errors="replace") as f:
return gcode_facts(f)
def sliced(path):
"""A sliced file's (.gcode.3mf) G-code entries, Metadata/plate_<n>.gcode, as {name: gcode_facts()} in name
order."""
with zipfile.ZipFile(path) as archive:
names = sorted(n for n in archive.namelist() if PLATE_GCODE.match(n))
out = {}
for name in names:
with archive.open(name) as entry:
out[name] = gcode_facts(io.TextIOWrapper(entry, encoding="utf-8", errors="replace"))
return out
def obj_facts(path):
"""An OBJ file's first line, its mtllib line, its numbers of `v` and `f` lines and its highest vertex z, as
{first, mtllib, v, f, top}."""
first, mtllib, v, f, top = None, None, 0, 0, None
with open(path, encoding="utf-8", errors="replace") as text:
for line in text:
if first is None:
first = line.rstrip("\r\n")
if line.startswith("mtllib "):
mtllib = line.strip()
elif line.startswith("v "):
v += 1
z = float(line.split()[3])
top = z if top is None else max(top, z)
elif line.startswith("f "):
f += 1
return {"first": first, "mtllib": mtllib, "v": v, "f": f, "top": top}
def reimport(client, path):
"""Imports a file into a new, empty project: project_new {discard_changes: true}, then project_import of the file.
Returns the import's reply and meshes()."""
run(client, "project_new", discard_changes=True)
reply = run(client, "project_import", paths=[path])
return reply, meshes(client)
def answer_all(client, checks, label, expected, timeout_s=30):
"""Answers OK, one at a time as each comes topmost, the dialogs a call opens, until it has answered one dialog for
each (title, words in its message) of `expected`, in whatever order they come. Each wait for the next is app_wait
{for: "dialog"}, and one that runs out raises TimeoutError. Then checks that no other dialog opened and that
dialogs() is empty."""
left, others = list(expected), []
while left and len(others) < 5:
wait(client, "dialog", timeout_s)
shown = dialogs(client)
if not shown: # closed between the wait and the read
continue
top = shown[-1]
match = next((e for e in left if e[0] == top["title"] and e[1] in (top["message"] or "")), None)
if match:
left.remove(match)
else:
others.append(top)
client.call("dialog_answer", dialog={"title": top["title"]}, button="OK")
checks.equal(f"{label}: no other dialog opened", others, [])
checks.equal(f"{label}: no dialog is left open", dialogs(client), [])
def slots(client):
"""The filament slots as filament_is_mixed from project_get_settings, one digit per slot ("0,0,1": three slots,
the third a mixed filament), as test_plates reads them."""
return client.call("project_get_settings", keys=["filament_is_mixed"])["items"][0]["value"]
+6 -4
View File
@@ -268,10 +268,10 @@ def crash_reports():
class Ports:
"""Hands out ports from FIRST_PORT up, passing over any something already listens on."""
"""Hands out ports from `first` up, passing over any something already listens on."""
def __init__(self):
self.next = FIRST_PORT
def __init__(self, first=FIRST_PORT):
self.next = first
def take(self):
while True:
@@ -348,6 +348,8 @@ def parse_args(argv=None):
help="run each app on a private compositor instead of on the desktop (Linux)")
ap.add_argument("--wayland", action="store_true",
help="run each app as a native Wayland client instead of as an X11 client (Linux)")
ap.add_argument("--first-port", type=int, default=FIRST_PORT, metavar="PORT",
help="the first port an app serves on, for sweeps run side by side (default: %(default)s)")
ap.add_argument("--list", action="store_true", help="print the order the tests would run in and exit")
return ap.parse_args(argv)
@@ -386,7 +388,7 @@ def main(argv=None):
crashes_before = crash_reports()
cond = threading.Condition()
ports, results, held, pending, stopping = Ports(), [], set(), list(parallel), threading.Event()
ports, results, held, pending, stopping = Ports(a.first_port), [], set(), list(parallel), threading.Event()
def run(name, port):
ctx = RunContext(mcp_dir=MCP_DIR, binary=binary, run_dir=os.path.join(out, name), port=port,
+12 -30
View File
@@ -1,42 +1,12 @@
{
"tests": {
"smoke_test": {"path": "smoke_test.json"},
"agent_forms": {"path": "tests/agent_forms.json"},
"cad_canvas": {"path": "tests/cad_canvas.json", "cad": true},
"cad_doc": {"path": "tests/cad_doc.json", "cad": true},
"cad_features": {"path": "tests/cad_features.json", "cad": true},
"cad_sketch_edit": {"path": "tests/cad_sketch_edit.json", "cad": true},
"cad_sketch_to_solid": {"path": "tests/cad_sketch_to_solid.json", "cad": true},
"cad_topology_targets": {"path": "tests/cad_topology_targets.json", "cad": true},
"calibration": {"path": "tests/calibration.json"},
"context_menus": {"path": "tests/context_menus.json"},
"dialogs_canvas_input": {"path": "tests/dialogs_canvas_input.json"},
"filaments_and_files": {"path": "tests/filaments_and_files.json"},
"gizmos": {"path": "tests/gizmos.json"},
"layers": {"path": "tests/layers.json"},
"multicolor": {"path": "tests/multicolor.json"},
"new_project_keeps_layer_gcode": {"path": "tests/new_project_keeps_layer_gcode.json"},
"objects_files": {"path": "tests/objects_files.json"},
"objects_order": {"path": "tests/objects_order.json"},
"objects_state": {"path": "tests/objects_state.json"},
"ops_assign_filament_preset_multi_slot": {"path": "tests/ops_assign_filament_preset_multi_slot.json"},
"ops_assign_filament_preset_one_slot": {"path": "tests/ops_assign_filament_preset_one_slot.json"},
"ops_open_project": {"path": "tests/ops_open_project.json"},
"ops_select_preset": {"path": "tests/ops_select_preset.json"},
"presets": {"path": "tests/presets.json"},
"presets_and_plate_map": {"path": "tests/presets_and_plate_map.json"},
"preview": {"path": "tests/preview.json"},
"recording": {"path": "tests/recording.json"},
"rows": {"path": "tests/rows.json"},
"menu_items_objects": {"path": "tests/menu_items_objects.json"},
"menu_items_placement": {"path": "tests/menu_items_placement.json"},
"menu_items_structure": {"path": "tests/menu_items_structure.json"},
"scene": {"path": "tests/scene.json"},
"settings_targets": {"path": "tests/settings_targets.json"},
"slice_stats": {"path": "tests/slice_stats.json"},
"actions_ask": {"path": "tests/actions_ask.json", "cad": true},
"view_switches": {"path": "tests/view_switches.json"},
"web_dialogs": {"path": "tests/web_dialogs.json"},
"test_action_replay_hidden": {"path": "test_action_replay_hidden.py"},
"test_additions_refusals": {"path": "test_additions_refusals.py"},
"test_cad_click_edit": {"path": "test_cad_click_edit.py", "cad": true},
@@ -60,6 +30,18 @@
"test_plugin_commands": {"path": "test_plugin_commands.py", "launch": "own", "args": ["--bin", "{bin}"]},
"test_plugin_tools": {"path": "test_plugin_tools.py", "launch": "own", "args": ["--bin", "{bin}"]},
"test_plates": {"path": "test_plates.py"},
"test_objects": {"path": "test_objects.py"},
"test_object_structure": {"path": "test_object_structure.py"},
"test_presets": {"path": "test_presets.py"},
"test_calibration": {"path": "test_calibration.py"},
"test_filaments": {"path": "test_filaments.py", "timeout_s": 1500},
"test_settings": {"path": "test_settings.py"},
"test_files": {"path": "test_files.py", "timeout_s": 1200},
"test_slice_preview": {"path": "test_slice_preview.py", "timeout_s": 1500},
"test_gizmos": {"path": "test_gizmos.py"},
"test_gui_tools": {"path": "test_gui_tools.py"},
"test_recording": {"path": "test_recording.py"},
"test_call_forms": {"path": "test_call_forms.py", "cad": true},
"test_preferences": {"path": "test_preferences.py"},
"test_printer_extruders": {"path": "test_printer_extruders.py", "launch": "own", "args": ["--bin", "{bin}"]},
"test_project_open_settings": {"path": "test_project_open_settings.py", "launch": "own", "args": ["--bin", "{bin}"]},
+6 -3
View File
@@ -10,9 +10,8 @@ in [TESTS.md](../TESTS.md).
**Decides by:** Exits 1 when any printed `FAIL` check fails. A call error, or an uncaught exception from a row's lambda, also fails the test. Every action runs; none is skipped. What "passes" means depends on the row:
- Common to every row that runs (all but the 3 refused): `... its reply names the action it ran` (`ran` == `orca_command:<key>:orca`, skipped for `export_config`, whose dialog is cancelled). `... the journal keeps its action_run with the arguments its command journals` requires an `action_run` step of that id whose inner `args` equal one value exactly:
- `{"test": "<name>"}`, the fixture's arguments, for the nine `calib_*` actions: their command, `calibration_generate_test`, journals its arguments, and the action's own fixed ones stand for them (`ActionContext::set_journal_args`).
- `{"percent": 50}` for `go_to_layer` and `{"tab": "preview"}` for `go_to_tab`, the values given for their input.
- `{}`, no `args`, for every other action: its command journals nothing of its own, or, as for `obj_arrange` and `start_recording`, its action's fixed arguments are empty.
- `{}`, no `args`, for every other action: its command journals nothing of its own, or, as for `obj_arrange` and `start_recording`, its action's fixed arguments are empty. The nine `calib_*` actions are among them: each opens its test's dialog (the person's form), and `calibration_generate_test` rewrites its journal entry (`ActionContext::set_journal_args`) only when it runs the test itself, with its parameters or `silent`.
The test's docstring, which says every step carries the fixture's arguments, says this instead: an `action_run` step with the id alone replays the same, since the action supplies its fixed arguments.
`... its action names the fixture's command` compares `action_search`'s `command` with the fixture's.
- Effect read back exactly, objects: `undo` (1 object), `redo` (2), `obj_delete` (only the other cube's id is left), `obj_delete_all` (none), `obj_mirror_x/y/z` (part centres move along that axis only, and instance `mirrored` is true), `obj_split_objects` (2 objects), `obj_split_parts` (1 object of 2 parts), `obj_center` (centre at 128,128 ±1 mm), `obj_drop` (min z 0 ±0.01), `obj_orient` (z size 20 ±0.5 after a 45° tilt), `obj_instances_up`/`obj_instances_down`/`obj_set_instances` (2/1/3 instances), `obj_instances_to_objects` (3 objects, 1 instance each), `obj_assemble` (1 object of 2 parts), the six `obj_type_*` (sorted part types), `obj_rename` (the typed name), the four `obj_order_by_*` (exact order), the ten `add_handy_*` (exact object names), `import_zip_archive` (1 object), `load_project` (2 objects, project path ends `load_me.3mf`), `new_project` (no objects).
@@ -32,6 +31,9 @@ in [TESTS.md](../TESTS.md).
- Loose effect checks where exact values are known: `calib_*` (only name and object count, not the generated test's objects), `add_primitive_*` (substring of the name), `obj_fit_volume` (> 200 mm), `obj_arrange` (on a plate; no positions, no overlap check), `view_fit_bed` (y of `look_at` unchecked), `reset_window_layout` (sidebar only), `toggle_run_script_panel` (any height change).
- `its action names the fixture's command` compares two static tables. It says nothing about what the action does.
**To settle in review:**
- That a calibration action's journal step has the id alone, not `{"test": "<name>"}`. The action runs its command's person form (`NativeCommands::with_person_form()`), which opens the test's dialog and journals nothing; only `calibration_generate_test`'s own run, with parameters or `silent`, calls `set_journal_args`, and `ActionContext` puts the action's fixed arguments in the step only in place of such a rewrite. Both are this branch's code (`McpToolsProject.cpp`, `McpPersonContext.hpp`, not on `main`). The step with the id alone replays the same, since the action supplies `test`.
**Strength:** Partial — about 70 actions have their effect read back exactly and about 23 loosely; 22 more only open a dialog, hand off, get refused or open a cancelled picker; and 12 export rows mostly check that a file exists. The journal step is pinned exactly for every action.
## `test_menu_items_refusals`
@@ -43,7 +45,7 @@ in [TESTS.md](../TESTS.md).
- Direct refusals: the error text holds a phrase and, where given, the details' `code` is exact (`gizmo_open`, `nothing_selected`, `one_object_only`, `wrong_selection`, `last_solid_part`, `cut_object`, `one_shell`, `auto_drop_question`, `no_such_plate` ×7, `no_objects_to_orient`, `not_printable` ×2, `not_renamed`).
- State after each refusal: `object_list` `total`, names, part ids and types, selection, `mirrored` flags, plate list (`name`, `locked`, `current`) and `rotation_deg`, all compared exactly with the state before.
- Picks: the expected notice text appears in `app_state.notifications`, or an auto-answer rule's `uses` rises by exactly 1 (Rename, last-solid-part message, cut question, Auto-Drop, Edit Plate Name). The state is then read back, for example Assemble on instance rows giving `[("other",1),("Assembly",2)]`.
- Notices two picks share: "Select two or more objects first." (Assemble with one object selected, then Assemble on every part row of an object) and "This acts on one object or part at a time: …" (Split to Objects on two instance rows, then Split to Parts on two part rows). A refused pick's notice is an error notice, which never fades, and the same text pushed again only moves the open one to the end of the list (`NotificationManager::activate_existing`). So before the second pick of each pair, the test closes the earlier notice. `widget_list` lists each notification as an `imgui_window` node for its ImGui window, `!!Ntfctn<id>`, with its text as a `text` node in it; the test finds the window whose text holds the notice's text and clicks its large invisible close button, which closes the notification in either theme. That button, labelled " ", and the close glyph beside it have labels the listing cleans to nothing and no `##` name, so `widget_list` lists neither and gives them no ref. The test reaches the invisible one with the locator `{imgui: "", window: "!!Ntfctn<id>", index: N - 1}`, which matches the window's unlabelled items in the order they are recorded; `render_close_button()` submits it last. N is the count the same locator without `index` is refused with ("N ImGui items match …; add \"index\""); it is at least 2, the glyph and the invisible button. A short refusal notice draws no minimize button (`m_multiline` with more than 3 lines only). "the earlier notice is closed" then waits up to 5 s, failing when the time runs out, for `app_state.notifications` to hold no notice with the text. After the second pick, its own check reads the text there again.
- Notices two picks share: "Select two or more objects first." (Assemble with one object selected, then Assemble on every part row of an object) and "This acts on one object or part at a time: …" (Split to Objects on two instance rows, then Split to Parts on two part rows). Both refusals' notices are regular ones (`menu_info()` answers them as information), which fade about 10 s after they show, so the first can still be open at the second pick, and while it is open the same text pushed again only moves it to the end of the list (`NotificationManager::activate_existing`). So before the second pick of each pair, the test closes the earlier notice; one that has already faded leaves nothing to close. `widget_list` lists each notification as an `imgui_window` node for its ImGui window, `!!Ntfctn<id>`, with its text as a `text` node in it; the test finds the window whose text holds the notice's text and clicks its large invisible close button, which closes the notification in either theme. That button, labelled " ", and the close glyph beside it have labels the listing cleans to nothing and no `##` name, so `widget_list` lists neither and gives them no ref. The test reaches the invisible one with the locator `{imgui: "", window: "!!Ntfctn<id>", index: N - 1}`, which matches the window's unlabelled items in the order they are recorded; `render_close_button()` submits it last. N is the count the same locator without `index` is refused with ("N ImGui items match …; add \"index\""); it is at least 2, the glyph and the invisible button. A short refusal notice draws no minimize button (`m_multiline` with more than 3 lines only). "the earlier notice is closed" then waits up to 5 s, failing when the time runs out, for `app_state.notifications` to hold no notice with the text. After the second pick, its own check reads the text there again.
- Results that run: `object_delete {}` on two solid parts (the remaining part ids, and the reply's `parts` and `kept`), `object_split keep_z` (2 objects, upper piece above 20 mm), the Auto-Drop "No" pick (pieces dropped below 1 mm), Duplicate Plate (`ops_undo.taken()` count 1, and undo restores 1 plate and 1 object), rename to the same name (no snapshot).
**Not checked:**
@@ -53,6 +55,7 @@ in [TESTS.md](../TESTS.md).
- `and takes no undo snapshot` reads the info-level log through `ops_undo.py`. It would pass if snapshots stopped being logged; the Duplicate Plate count-1 check in the same run would catch that.
**To settle in review:**
- The notices the pairs share are regular notices, not error notices that never fade: `menu_info()` (`McpToolsScene.cpp`, from commits not on `main`) answers `too_few_objects` and `one_object_only` as information, as the menu items told them, since the person can select something else and pick again. So the first notice may fade before the second pick, and the close step then finds nothing; "the earlier notice is closed" still reads the text gone before the second pick, and that pick's own check reads it shown again.
- Reaching the close button through a refusal's count is roundabout. Naming the button in the app (`record_named_item` on the close button in `render_close_button()`) would let the test click it by name; that is a change to the app.
**Strength:** Strong — refusal codes and the state after each refusal are compared exactly, and each pick's notice is its own; only a few picks rest on notice text alone.
+26 -95
View File
@@ -11,8 +11,7 @@ so the sweep can run them side by side; `test_filaments` also needs presets that
app gives it.
## `test_filaments`
`test_filaments.py` · Python · takes the place of `ops_assign_filament_preset_one_slot.json`,
`ops_assign_filament_preset_multi_slot.json` and `multicolor.json`
`test_filaments.py` · Python, 479 checks · in `sweep.json` as `{"path": "test_filaments.py", "timeout_s": 1500}`
**Tests:** Assigning a filament preset to a filament slot through each route a person or a plugin has: a pick in the
slot's selector in the sidebar, the selector's value set (`widget_set_value`), `preset_select`, and the plugin API's
@@ -183,9 +182,11 @@ on slot 2: the pick and the tool leave the tab on `B`, the api moves it to the p
After the filament rows of each preference, one more case from the same start: `project_set_settings {values:
{filament_colour: {index: 1, value: "#FFF8E7"}}}`, the colour picker's change. Under All and Color it leaves `B B B | B
| 4,4,4 | cX | R2`; under None `B B B | B | 4,4,4 | cX | S3`. Where `R2` is expected, the three routes and the colour
change give the same four entries under one preference, and Color gives what All gave for `X`: an assignment
recalculates as a colour change does.
| 4,4,4 | cX | R2`; under None `B B B | B | 4,4,4 | cX | S3`. Where `R2` is expected, the three routes of `X` give the
same four entries under one preference, and Color gives what All gave for `X`: an assignment recalculates as a colour
change does. The colour change gives the routes' entries 1 and 7, into slot 2, and lower entries 3 and 5, out of it:
slot 2 still holds `B`, whose retraction at a cut the calculator takes off the flush out of the slot, where `X` has none
(see To settle).
**Scenario: three slots, unsaved changes in the preset the tab edits**
@@ -304,6 +305,13 @@ is `[B, M]`. `project()` is read after every step; a value it gives is written o
lighter colour above those out of it. With the X1C's `nozzle_flush_dataset` 0, `FlushVolCalculator::calc_flush_vol_rgb()`
takes the flush predictor's value where it has one and its colour formula otherwise; both make a dark-to-light change
cost far more than the reverse.
- The colour change and the assignment of `X` agree only on the volumes into slot 2. The calculator works out a change
from the minimum of the filament it leaves (`get_min_flush_volumes()` in `Plater.cpp`, the app's own code, given to
`FlushVolCalculator` by `Sidebar::auto_calc_flushing_volumes_internal()`): the nozzle volume, 107 mm³ on the X1C, less
the filament the printer retracts at a cut. `B` retracts 18 mm at a cut
(`filament_long_retractions_when_cut` 1), about 44 mm³, while `X` sets no such retraction, so with `B` still in slot 2
the colour change gives entries 3 and 5 lower (on this build 148 and 138 against 192 and 182). The rows check the
order, not the difference.
- `Sup` is exact: 230 into a support filament and `max(<colour volume>, 700)` out of it
(`Sidebar::auto_calc_flushing_volumes_internal()`); from `#222222` to `#111111` or `#333333` the colour volume plus the
calculator's minimum (the X1C's 107 mm³ nozzle volume, less the cut retraction where it applies) stays far under 700.
@@ -316,10 +324,10 @@ is `[B, M]`. `project()` is read after every step; a value it gives is written o
each tool change). Entry 1 at 400 or 200 times 0.7 (280 or 140 mm³) is above 107 either way, so a change from slot 1
to slot 2 charges slot 1 107 mm³ in both slices and slot 2 the rest, and the changes from slot 2 to slot 1 are the
same: slot 1's `flush_g` stays to 0.01 g while slot 2's falls. At 1.4 both entries grow and so do both slots' grams.
- The preference is set with `preferences_set`, where the replays picked it in the Preferences dialog; the dialog's
- The preference is set with `preferences_set`, not picked in the Preferences dialog; the dialog's
choice control writes the same key (`PreferenceOps.cpp`), and `test_preferences` checks the dialog against
`preferences_get`.
- Run time: about 60 assignment cases and six slices; the entry may need a `timeout_s` above 900 in `sweep.json`.
- Run time: about 60 assignment cases and six slices, about 11 minutes on Windows, so `sweep.json` gives it 1500 s.
**Not checked:**
- Adding and deleting slots, and the mixed filament's rules: `test_plates` (its filament slots scenario). Assigning a
@@ -334,7 +342,7 @@ is `[B, M]`. `project()` is read after every step; a value it gives is written o
- `filament_colour_type` and `filament_multi_colour`, which `update_ams_color()` writes beside `filament_colour`: no
MCP tool lists them, and for a preset that is not an AMS slot's they only mirror `filament_colour` (an empty type,
the colour itself).
- A text part made with the Text gizmo, which `multicolor.json` gave filament 2: the second part here is a cube from
- A text part made with the Text gizmo: the second part here is a cube from
`part_add`. Both are model parts, which `settings_set` gives a filament the same way; the gizmo is not this area's.
- How the sidebar shows a slot: the colour swatch and the badge are not read, and no screenshot is taken.
- A printer with several extruders, where the filament grouping applies: `test_printer_extruders`.
@@ -343,8 +351,13 @@ is `[B, M]`. `project()` is read after every step; a value it gives is written o
**Fixtures:** none; the plugin API calls are the test's own code.
**Strength:** Strong — after every case it compares the slots, the tab, the unsaved values, the colours and the
flushing volumes whole with the state written out here, asserts the prompt, each reply and each refusal or raise
exactly, checks the volumes the app works out by stated properties, and shows the filaments and the flush settings in
the print and in the project file.
## `test_settings`
`test_settings.py` · Python · takes the place of `settings_targets.json` and its fixture `tests/fixtures/settings_targets.py`
`test_settings.py` · Python, 72 checks · in `sweep.json` as `{"path": "test_settings.py"}`
**Tests:** The settings commands' targets. `settings_list` giving a type's settings whole, a saved preset's and a
filament slot's, and the settings an object and a region take; then `settings_set` and `settings_get` on an object, a
@@ -451,90 +464,8 @@ layer of `layers()` 0.2 mm high to 0.001 mm, and the layers at z 3.0 and 15.0 mm
- Which object list keys are object-only: the scenario checks the lists against the process and each other, and a few
known keys.
**Fixtures:** none; `tests/fixtures/settings_targets.py` leaves with the replay.
**Fixtures:** none.
## Replays this area replaces
Each leaves the sweep, with its entry, in the commit that adds the tests above.
### `ops_assign_filament_preset_one_slot`
`tests/ops_assign_filament_preset_one_slot.json` · replay, 258 steps, 90 expects, 69 optional
**Tests:** Assigning a filament preset to the only slot, where the assignment also switches the filament tab and its unsaved-changes prompt applies. Each route (sidebar, `preset_select`, plugin API `begin_update(1, name)`) for a PLA (Transfer offered) and a support filament of another type (no Transfer), without and with unsaved changes, with each `preset_changes` value and none, and the prompt answered each way. Then the plugin API forms that name no preset.
**Decides by:** Fails when a non-optional call errors, a fixture raises, or an expect misses. Every expect sits on setup.
- Case setup (`arrange_filaments`, 32 steps): no dialog open, `flush_volumes_matrix` eq `0`, and ` (modified)` on the filament tab in dirty cases.
- Setup: one slot; `auto_calculate_flush` reads `all`.
- Implicit: non-optional calls must succeed without a prompt: the clean sidebar picks, `preset_select` with no `preset_changes` on a clean tab, `transfer` and `discard` for the PLA, `discard` for the support filament. The `await: false` calls in the dirty cases must not be refused at once.
**Not checked:**
- No `probe()` after a call is asserted: whether the slot changed, the tab switched, the edits were transferred or dropped, or the colour settings were written.
- Whether the prompt opens and offers Transfer for the PLA but not for the support filament: `app_wait {for: dialog}` cannot fail, and the answers are optional. `preset_changes: "transfer"` for the support filament is optional, so neither its refusal nor its acceptance is checked.
- The plugin API route cannot fail (`preset_api` catches exceptions), including the `update`/`begin_update` forms without a name.
- `undo_taken` is never asserted.
**Strength:** Smoke — the tool and sidebar routes must succeed without a prompt, but nothing a call leaves is asserted.
### `ops_assign_filament_preset_multi_slot`
`tests/ops_assign_filament_preset_multi_slot.json` · replay, 303 steps, 110 expects, 32 optional
**Tests:** Assigning a filament preset to slot 2 of three through the sidebar selector (row click, and once `widget_set_value`), `preset_select` and the plugin API's `filament.begin_update(2, name)`, under each Auto-flush preference (All, Color, None), for a PLA with a default colour, one without, and a support filament. Then the plugin API's other forms, unsaved changes in the filament the tab edits, the refusals (no such slot, no such name, an incompatible preset, a mixed-colour slot) and a hidden preset.
**Decides by:** Fails when a non-optional call errors, a fixture raises, or an expect misses. Every expect sits on setup; none is on what a call under test left.
- Case setup (`arrange_filaments`, 46 steps): no dialog open (`/result/dialogs` empty), `flush_volumes_matrix` equal to the sentinels `0,777,777,777,0,777,777,777,0`, and in the dirty cases a filament tab name ending ` (modified)`. Because no dialog may be open, a prompt the previous case left open fails the next case.
- Preferences: `auto_calculate_flush` reads `all`, `color change`, `disabled` after each pick in the Preferences dialog.
- Setup: three slots (`/presets/filaments/2` exists, `/3` does not). The Add Mixed Filament dialog opens (title eq), `filament_is_mixed` becomes `0,0,0,1` and goes back to `0,0,0`.
- Implicit: the non-optional `preset_select` calls and sidebar row clicks must not be refused and must not open a prompt, since an awaited call held by a dialog times out after 120 s and fails. That includes the hidden `Bambu PETG Basic` through `preset_select`.
**Not checked:**
- The `probe()` after each call has no expect. The slot mapping, the edited filament preset, the three colour settings, the project's colours and the flushing volumes are only recorded, so whether the flush matrix is recalculated under All, Color or None (the reason for the three passes) is never asserted.
- Every plugin API call goes through `ops_presets.preset_api`, which catches any exception and returns it as data. That route cannot fail any case, including the assignments that should succeed and the hidden `Bambu PETG HF`.
- The refusals (slots 5 and 0, `No Such Filament`, `Bambu PLA Basic @BBL A1`, the mixed slot, `begin_update` without a slot) are optional `preset_select` steps or caught exceptions. Neither the refusal nor its code or text is asserted.
- The unsaved-changes prompt: `app_wait {for: dialog}` returns `satisfied: false` on timeout without failing, and the Transfer/Discard/cancel `dialog_answer` steps and "second prompt" waits are optional. Whether a prompt opens, and which buttons it offers, is not checked.
- `undo_taken` is never asserted.
- `arrange_filaments` does not assert the slots it set (`/result/slots`).
**Strength:** Smoke — the tool and sidebar routes must succeed without a prompt, but nothing a call leaves is asserted.
### `multicolor`
`tests/multicolor.json` · replay, 56 steps, 26 expects, 5 optional
**Tests:** Filaments assigned to objects and parts through `settings_set`'s object and part targets, read back with `settings_get`'s effective value and source, with undo and redo; then the project's slot colours, flush multiplier, a flush-matrix entry, plate type and prime tower position through `project_set_settings`, refusals that should change nothing, and a slice.
**Decides by:** Fails when a non-optional call errors or one of its 55 matchers misses.
- Object filament: `/applied/extruder` = `"2"`; effective `"2"` with source `object` on object 1, `"1"` on object 0; undo gives `"1"`, redo `"2"`.
- Parts: part 0 of a one-part object sets the object (`"1"`, with a `/note`); a text part takes `"2"` with source `part` and is listed under the object's `/items/0/parts/0` (part 1, `"2"`); `null` resets it to the object's `"1"`.
- One undo step: after `extruder` and `wall_loops` in one call and an undo, `extruder` effective `"1"`, the part's `"2"` back, `wall_loops` value null with source `global`.
- Project settings: meta (`read_only`, `offered`), `filament_colour` `^#FFFFFF;#000000`, `flush_multiplier` `"0.7"`, matrix `^0,400,` and bed type, all read back with `project_get_settings`; after four refused calls the colour, multiplier, matrix and `filament_is_mixed` still match.
- Prime tower: x/y set to 150/180, then x to 40, undo back to 150/180.
- Slice: `/status` = `done`, outcome `ok`.
**Not checked:**
- The refused `prime_volume_mode: "Saving"` and `wipe_tower_x: 300` calls are optional and never read back; if either were accepted the test still passes.
- The refused colour `"white"` targets slot 0, which is already `#FFFFFF`; only the multiplier in the same call shows the call was refused.
- The slice is checked only for `ok`; nothing shows the cylinder and the text part print with filament 2.
- `Add one filament` is checked only by `/presets/filaments/1` existing, which a datadir with several slots satisfies without the click.
- `/note` matchers are `exists`; `filaments.png` is saved and never compared.
**Strength:** Partial — filament targets and project settings are read back exactly, but two refusals and the slice's use of filament 2 are unchecked.
### `settings_targets`
`tests/settings_targets.json` · replay, 39 steps, 83 expects, 0 optional
**Tests:** `settings_list` returning a type whole, a saved preset's and a slot's values, and what an object and a region take; `settings_set`/`settings_get` on targets object, part and height range by index and from the selection, with `effective` and `source` in the slicer's precedence; ranges replaced keeping the one that stays.
**Decides by:** Fails when a call errors, a fixture raises, or an expect misses.
- Whole lists (`listing()`): process ≥ 300, printer and filament > 100 settings, items equal to total, no next page; with meta 100 a page and `limit` 50 pages without meta.
- Values (`value_of()`): `layer_height` "0.2", "0.16" in the named saved preset, slot 2 "PETG", slot 1 "PLA".
- `nested()`: the object list has > 200 keys, all process keys with the process's values; the region list > 100 keys, all object keys except `layer_height`, whose targets are exactly ["height_range"].
- Per target: `settings_set` replies `applied` and name the object, part or range; `object_list` reads the range values "6" and "0.12"; `overrides()` lists each target's own overrides (4, 5, 6; the range also has `layer_height`, no `extruder`).
- Precedence: the selected part reads "5" from source "part"; the modifier over a part that sets `sparse_infill_density` reads source "overlapped_part" with the part's "30%" and a note; the object reads effective "4" with the part's "5" and range's "6"; the range reads effective "6" from "height_range" and the density null from "global"; the selected object stands for the range target ("0.12").
- Replacing ranges keeps the lower range's "6", gives the new upper range `max_z` 12 at "0.2" with no `wall_loops`; the plate slices "ok".
- Fixture `settings_targets.py` asserts nothing; it returns totals, values and key lists computed from the tools' replies.
**Not checked:**
- The slice is checked only as "ok"; no printed result shows the object, part or range `wall_loops`.
- `nested()` compares two `settings_list` views with each other, not with known values, so a fault shared by both passes.
- Loose: list totals as lower bounds; the range's `layer_height` override and `object_effective` checked with `exists` where the values are known; `settings_get {target: part}` without keys checks only that an item has a key.
**Strength:** Strong — target naming, values, effective values and sources are matched exactly for every target.
**Strength:** Strong — it compares every target's settings whole after each step, asserts each value's effective value,
source and note exactly, checks the lists whole and paged against each other and known values, and shows the targets'
walls, infill and layer heights in the print against a control slice.
+14 -72
View File
@@ -4,8 +4,7 @@ The design of this area's sweep tests. The rules every entry follows, the grades
in [TESTS.md](../TESTS.md).
## `test_files`
`test_files.py` · Python · takes the place of `filaments_and_files.json`, `new_project_keeps_layer_gcode.json` and
`ops_open_project.json` · in `sweep.json` as `{"path": "test_files.py", "timeout_s": 1200}`
`test_files.py` · Python, 577 checks · in `sweep.json` as `{"path": "test_files.py", "timeout_s": 1200}`
**Tests:** What the project's files do: a new project and the question New Project asks about unsaved changes; opening
a project file and saving one under a name; importing models (STL, a project's `.3mf`, a ZIP archive, a STEP file and
@@ -21,10 +20,7 @@ imports, written with `zipfile` and an ASCII STL writer of its own, and every fi
`tests/data/test_stl/ASCII/20mmbox-LF.stl` (a 20 mm box, 12 triangles), `tests/data/named_single_body.step` (a
tetrahedron with 10 mm legs: 4 triangles, 166.667 mm³), `resources/handy_models/3DBenchy.drc`, and
`tools/mcp/tests/fixtures/heightmap.png` and `mcp_import_pla.json` (a filament preset, `MCP Import PLA`). It does not
use `tests/fixtures/filaments_and_files.py`. When the replay leaves, that fixture keeps what
`test_additions_refusals.py` imports from it: `write_zip(args)` (`args` `name` and `cubes`, `{entry: size}`; returns
`{path}`), with the `folder()` and `cube_stl()` it calls. Its `export`, `write_project_zip` and `import_zip` and the
docstring's mention of the replay go with the replay.
use `tests/fixtures/filaments_and_files.py`, which `test_additions_refusals.py` writes its archive with.
**Reads:** `plates()` and `slots()` as `test_plates` reads them. New readers in `checks.py`:
- `project()`: `app_state.project`, whose fields are `name`, `path` and `dirty`, as `{name, file, dirty}`: `file` is
@@ -49,7 +45,8 @@ docstring's mention of the replay go with the replay.
- `sliced(path)`: the names of a `.gcode.3mf`'s G-code entries (`Metadata/plate_<n>.gcode`), sorted, and the `gcode()`
of each.
- `obj_facts(path)`: an OBJ's first line, its `mtllib` line, its numbers of `v` and `f` lines and its highest vertex z.
- `reimport(path)`: `project_new {discard_changes: true}`, then `project_import {paths: [path]}`, then `meshes()`.
- `reimport(path)`: `project_new {discard_changes: true}`, then `project_import {paths: [path]}`; it gives the
import's reply and then `meshes()`.
- `answer_all(expected)`: answers the dialogs a call opens, each OK as it comes topmost, waiting with `app_wait {for:
"dialog"}` (a wait that runs out fails) until it has answered one dialog for each `{title, message words}` in
`expected`, in whatever order they come; it checks that no other dialog opened and that `dialogs()` is then empty.
@@ -242,10 +239,10 @@ step 2: `[true]`, from step 3: `[true, false]`), and `undo_steps()` is `[]` unle
| 3 | `plate_add`, then `object_add_primitive {shape: "cube", size: [20, 20, 20], name: "b", plate: 1}`, `plate_slice {plates: 0}`, `plate_select {plate: 0}` | `"" 1 *` · `"" 1` | outcome `ok`, `layers` 100 |
| 4 | `project_export {format: "sliced_3mf", path: W/half_current.gcode.3mf}` | as after 3 | `sliced()` `[Metadata/plate_1.gcode]` |
| 5 | the same with `plates: "all"`, to `W/half_all.gcode.3mf` | as after 3 | `sliced()` `[Metadata/plate_1.gcode]`: plate 1, not sliced, adds none |
| 6 | the same with `plates: 1`, to `W/half_1.gcode.3mf` | `"" 1` · `"" 1 *` | `sliced()` holds no G-code entry; the plate named is made current first, `undo_steps()` `["select partplate!"]` |
| 6 | the same with `plates: 1`, to `W/half_1.gcode.3mf` | `"" 1` · `"" 1 *` | `sliced()` holds no G-code entry; the plate named is made current first, `undo_steps()` `["select partplate!", "select partplate!"]` |
| 7 | the same with no `plates`, to `W/from_1.gcode.3mf` | as after 6 | `sliced()` holds no G-code entry |
| 8 | the same with `plates: "all"`, to `W/all_from_1.gcode.3mf` | as after 6 | `sliced()` `[Metadata/plate_1.gcode]` |
| 9 | the same with `plates: 0`, to `W/half_0.gcode.3mf` | `"" 1 *` · `"" 1` | `sliced()` `[Metadata/plate_1.gcode]`; `undo_steps()` `["select partplate!"]` |
| 9 | the same with `plates: 0`, to `W/half_0.gcode.3mf` | `"" 1 *` · `"" 1` | `sliced()` `[Metadata/plate_1.gcode]`; `undo_steps()` `["select partplate!", "select partplate!"]` |
| 10 | `project_export {format: "gcode", path: W/plate_1.gcode, plates: 1}` | `"" 1 *` · `"" 1` | refused, `plate_not_sliced`; no file; `undo_steps()` `[]`: a refused export leaves the current plate and the undo history as they were |
**Scenario: a G-code export refused**
@@ -329,8 +326,8 @@ Objects are read with `meshes()` as their names and `filament`; `colours` is `fi
**To settle in review:**
- A refused export of a plate by index selects the plate first (sliced file, step 10). `Ops::start_gcode_export()`
(`src/slic3r/GUI/Operations/ExportOps.cpp`) calls `plater.select_plate(*args.plate)` and only then
`Plater::export_gcode_to()`, which refuses an unsliced plate, so the refusal leaves plate 1 current and a "select
partplate!" undo step (`Plater::select_plate()` takes `take_plate_selection_snapshot()`). The fix, in
`Plater::export_gcode_to()`, which refuses an unsliced plate, so the refusal leaves plate 1 current and its "select
partplate!" undo steps (`Plater::select_plate()` takes `take_plate_selection_snapshot()`). The fix, in
`ExportOps.cpp`: an export that names a plate refuses, on that plate and before it selects it, all it can know
there. `start_gcode_export()` makes `export_gcode_to()`'s checks in its order on the named plate:
`plater.is_export_gcode_scheduled()` (`export_already_running`), `plater.is_slicing_any()` (`slicing_in_progress`),
@@ -340,8 +337,13 @@ Objects are read with `meshes()` as their names and `filament`; `colours` is `fi
fail only once the export runs on the selected plate (`export_not_started`; `sliced_file_not_written` for a
configuration that fails validation, a post-processing script that fails on a printer outside the Bambu network, or a
failed write; `file_not_written` of `export_model_3mf()` and `export_stl()`) selects the plate that was current back,
so the current plate is as it was, with the two selection steps left in the undo history. The step expects the fixed
so the current plate is as it was, with both selections' steps left in the undo history. The step expects the fixed
behaviour: plate 0 current and no undo step.
- Making another plate current logs two "select partplate!" undo steps (sliced file, steps 6 and 9):
`Plater::select_plate()` takes one, and `PartPlateList::select_plate()` takes another when the index changes
(`PartPlate.cpp`, "erase unnecessary snapshot"). This is the app's own code, left as it is: `main` takes both
snapshots (`take_snapshot("select partplate!")` in each function); this branch only routes them through
`take_plate_selection_snapshot()`. The steps expect the two.
- An object index the project lacks (exporting meshes, step 8) is refused by the target check,
`IndexCheck::object()` (`src/slic3r/GUI/Mcp/McpTargets.cpp`), with "object index 5 is out of range" and no code,
before `Ops::export_objects_refusal()` runs, so the export's own refusal for it, `no_such_object`, never answers. The
@@ -423,63 +425,3 @@ Objects are read with `meshes()` as their names and `filament`; `colours` is `fi
**Strength:** Strong — every export and save is read back from its file, and every refusal by its code or words with
the state written out after it.
## Replays this area replaces
Each leaves the sweep, with its entry, in the commit that adds the tests above.
### `filaments_and_files`
`tests/filaments_and_files.json` · replay, 65 steps, 71 expects, 0 optional
**Tests:** `filament_delete` merging slot 2 into slot 1, `filament_add_mixed` (and the same mix again), `project_export` of some objects and of each object as STL and DRC and of the Preview's toolpaths as OBJ, `project_import` of a ZIP's named entries, of all its models, and of a ZIP holding one project, and the STEP mesh-options dialog for `project_import`, `part_add` and `part_replace`.
**Decides by:** Fails when a call errors, a fixture raises, or an expect misses.
- Slots: `filament_add` replies slots 2 and 3; the object on slot 2 prints with slot 1 after the merge, whose reply gives `merged_into` 1 and 2 slots.
- Mixed: the reply adds slot 3; `filament_is_mixed` is "0,0,1"; the same mix replies `added` false and no fourth slot appears.
- Exports through `export()`, which reads each written file's size from disk: STL replies name the objects, `bytes` 684 for one cube and 1284 for two, and per-object exports write exactly two files of 684 bytes; DRC replies and files > 0 bytes; the toolpaths OBJ after a Preview slice > 0 bytes.
- ZIP: named entries add 2 objects, named "large.stl" then "small.stl" with volumes 8000 and 1000; one "Import Objects: cubes.zip" snapshot; no dialog; all entries add 3 (the readme is skipped).
- Project ZIP: adds 1 object from entry "project.3mf" after the two there, no dialog, the project path stays "", one "Import Objects: project.zip" snapshot.
- STEP: each call runs with `await: false`, the dialog titled "STEP file import parameters" is answered, the job is waited for; then 1 object with one part, two parts after `part_add`, still two after `part_replace`.
- Fixture `filaments_and_files.py` asserts nothing: it writes files and archives, calls tools and returns replies and on-disk sizes; a tool error raises `ToolError`.
**Not checked:**
- STL byte sizes depend only on triangle count: the per-object "big.stl" eq 684 passes whatever cube it holds, and no export is re-imported.
- DRC exports and the toolpaths OBJ are checked only as non-empty.
- STEP: the `app_wait {for: job}` steps have no expect, so a job still running after 30 s passes; `part_replace`'s effect is not checked (the follow-up also holds if it changed nothing); the `blocked_by_dialog` reply the header describes is not asserted.
**Strength:** Partial — slots, STL sizes and ZIP imports are exact, but DRC and toolpath exports are only non-empty and the STEP replace is only run.
### `new_project_keeps_layer_gcode`
`tests/new_project_keeps_layer_gcode.json` · replay, 22 steps, 6 expects, 0 optional
**Tests:** New Project's question about unsaved changes keeps the plate's layer G-code (a pause at layer 26) whatever the answer: Cancel leaves it on the project, and Save writes it to the project's file before the new project starts.
**Decides by:** Fails when a call errors (including `dialog_answer` finding no dialog titled "- Save", or the action's job failing) or one of its 13 matchers misses.
- Setup: one object, slice `done`/`ok`, `plate_set_custom_gcode` gives exactly one `pause`.
- Cancel: `plate_list` still has 1 object and exactly one `pause`.
- Save: the new project has 0 objects and `layer_gcode` = []; reopening `kept.3mf` gives 1 object and exactly one `pause`.
**Not checked:**
- Save: `kept.3mf` already holds the pause from the explicit `project_save` before the 5 mm move, so the reopen catches a Save that writes the file without the pause but not a Save that writes nothing; the move only Save would store is never read back.
- Only each layer G-code's `type` is read, not its layer (26).
**Strength:** Partial — Cancel is checked, but whether the dialog's Save wrote the file cannot be told from the earlier `project_save`.
### `ops_open_project`
`tests/ops_open_project.json` · replay, 54 steps, 18 expects, 7 optional
**Tests:** `project_open` with a `.3mf` path: on a clean project; on one with unsaved project changes (a cylinder), refused and then opened with `discard_changes`; on an empty one with unsaved preset changes (`top_shell_layers` 7), refused and then opened with `discard_changes` after its presets dialog is answered Discard.
**Decides by:** Fails when a non-optional call errors or an expect misses. The `project_open` calls are optional, but the state read after the refused and discarding cases is asserted.
- Refused, dirty project: still dirty, no dialog, one object named `Cylinder`.
- `discard_changes`: name `open_src`, not dirty, one object named `Cube`.
- Refused, dirty presets: no dialog, no objects, `top_shell_layers` still `7`.
- `discard_changes` with dirty presets: a dialog whose title matches `unsaved changes` is open; after Discard the name is `open_src`, no dialog, one `Cube`, `wall_loops` `5` and `top_shell_layers` not `7`.
**Not checked:**
- The clean open: its `project_open` is optional and nothing read after it (`app_state`, `object_list`, `settings_get`, recent projects) has an expect, so a clean open that fails passes.
- The refusal's code (`unsaved_changes`) and text; only the state it leaves is checked.
- The dirty flag after the preset-case open, the recent projects, the undo snapshots and the `compare: ":saved"` reads.
- `top_shell_layers` is checked with `ne "7"` rather than the value the opened project gives.
**Strength:** Partial — the refused and discarding cases' state is checked exactly; the clean open and the refusal codes are not.
+43 -71
View File
@@ -4,7 +4,7 @@ The design of this area's sweep tests. The rules every entry follows, the grades
in [TESTS.md](../TESTS.md).
## `test_gizmos`
`test_gizmos.py` · Python · takes the place of `gizmos.json` and `dialogs_canvas_input.json`
`test_gizmos.py` · Python, 622 checks · in `sweep.json` as `{"path": "test_gizmos.py"}`
**Tests:** The Prepare view's gizmos driven as a person drives them, through the generic GUI tools: gizmo icons,
fields, combos, buttons and links in their panels, and clicks and strokes at points of the model. Each gizmo's work
@@ -21,7 +21,9 @@ the preset prompt. It runs on the harness's default printer, the Bambu Lab X1 Ca
mesh_volume, bbox, painted, text, svg}`.
- `gizmo()` gives `app_state.gizmo` as `{name, canvas}`, or none.
- `panel()` gives the open gizmo's ImGui panel as `widget_list` lists it: its texts in order, and its named items
with the value each shows (a field's text, a combo's choice).
with the value each shows (a field's text, a combo's choice), an item without a name by its label. The panel is
the largest ImGui window that is not a notification, since Measure draws the labels of its results on the canvas
in small windows of their own.
- `assembly()` gives each object's position in the assemble view, `assemble_offset()` of its instance 0, from a
`script_run` that reads `orca.host.model()`. No other tool reports it: `object_list` gives the Prepare placement.
- `setting(object, key)` gives `settings_get {target: object}`'s `{value, effective, source}` for one key.
@@ -46,15 +48,18 @@ assemble view). Each opening replies `active: true` and is followed by `gizmo()`
closing, by that second click or by the panel's Done, Close or Return button, is followed by `gizmo()` none. The rows
below do not repeat this. A `widget_set_value` reply, the value as the field shows it, is checked too, never instead
of the read-back. A step that starts a job in the background says "then idle": it is followed by `app_wait {for:
"idle"}` before its read-back, and that wait must be met. Those are every edit in the Text panel, `object_add_svg`,
`svg_change`, a texture stroke, Simplify's ratio and Apply, Mesh Boolean's Union, the cut and the variable layer
height panel's Adaptive. Simplify's first ratio is the one such step without a wait, on purpose.
"idle"}` before its read-back, and that wait must be met. Those are the Text icon that creates a text part, every
edit in the Text panel, `object_add_svg`, `svg_change`, a texture stroke, Simplify's ratio and Apply, Mesh Boolean's
Union, the cut and the variable layer height panel's Adaptive. Simplify's first ratio is the one such step without a
wait, on purpose.
**Scenario: prompts a rule answers**
The preset prompt that asks to transfer or discard unsaved changes is answered by an auto-answer rule naming the
button. `wall_loops` is read with `settings_get {type: "process"}` and the selected process preset from
`app_state`. Both presets inherit `wall_loops` "2" from `fdm_process_common`.
`app_state`. Both presets inherit `wall_loops` "2" from `fdm_process_common`. A rule presses its button once the
prompt's modal loop runs (`ModalTracker::Enter`), so a switch the prompt holds may first reply `blocked_by_dialog`;
the test follows its job to the end with `app_wait {for: "job"}` and checks the job's reply.
| # | Step | Process after | Also checked |
|---|---|---|---|
@@ -76,12 +81,12 @@ A 20 mm cube A at (100, 100), selected, the camera at `iso` and fitted to the ob
| 3 | `undo` | A (100, 100, 10) | |
| 4 | `redo` | A (90, 100, 10) | |
| 5 | Move closed, `object_transform {object: 0, rotate: [0, 0, 90], mode: "absolute"}`, Move opened, `widget_set_value {target: {imgui_name: "coordinates"}, value: "Object"}` | A (90, 100, 10) rot [0, 0, 90] size [20, 20, 20] | reply `selected: "Object"`; `panel()` shows the caption `Relative` where it showed `Position`, and `position_x` reads `0.00` |
| 6 | `position_x` set to 10 | A (90, 110, 10) rot [0, 0, 90] | the move goes along A's own X axis, which the turn points along the bed's +Y |
| 6 | `position_x` set to 10 | A (90, 110, 10) rot [0, 0, 90] | the edit goes through, though the field moves A by what it is given and then reads `0.00` again; the move goes along A's own X axis, which the turn points along the bed's +Y |
| 7 | `coordinates` set to index 0 | as after 6 | reply `selected: "World"`; `panel()` shows `Position`, and `position_x` reads `90.00` |
| 8 | Move closed, Rotate opened, `absolute_rotation_z` set to 30 | A (90, 110, 10) rot [0, 0, 30] size [27.32, 27.32, 20] to 0.01 | reply `30.00` |
| 9 | `undo` | rot [0, 0, 90] size [20, 20, 20] | |
| 10 | `redo` | as after 8 | |
| 11 | `absolute_rotation_z` set to 0 | A (90, 110, 10) rot [0, 0, 0] size [20, 20, 20] | |
| 11 | `absolute_rotation_z` set to 0 | A (90, 110, 10) rot [0, 0, 0] size [20, 20, 20] | the edit goes through, though the panel then shows the turn as [180, 180, 180], the same turn as none (`get_rotation_by_quaternion` in `GizmoObjectManipulation.cpp`) |
| 12 | Rotate closed, Scale opened, `scale_x` set to 120 | A (90, 110, 12) scale 1.2 size [24, 24, 24] | reply `120.00`; uniform scale is on, so all three axes; A rests on the bed (`bbox.min` z 0) |
| 13 | `undo` | A (90, 110, 10) scale 1 size [20, 20, 20] | |
| 14 | `redo` | as after 12 | |
@@ -126,7 +131,7 @@ fills the face it lands on: the two triangles of a cube's face.
| # | Step | Painted after | Also checked |
|---|---|---|---|
| 0 | start | no `painted` | the cube (100, 100, 10) size [20, 20, 20], one part with 12 triangles; `slots()` "0,0"; `setting(0, "enable_support")` value true from `object` |
| 0 | start | no `painted` | the cube (100, 100, 10) size [20, 20, 20], one part with 12 triangles; `slots()` "0,0"; `setting(0, "enable_support")` value and effective "1" from `object` (`settings_get` gives a value as the config writes it, a switch as "1" or "0") |
| 1 | Support Painting (`FdmSupports`) opened, `{imgui_name: "Fill"}` clicked, then `mouse_gesture {at: {object: 0, spot: "front"}}` | supports 2/0 | |
| 2 | `undo` | no `painted` | |
| 3 | `redo` | supports 2/0 | |
@@ -143,7 +148,7 @@ fills the face it lands on: the two triangles of a cube's face.
| 14 | Color Painting opened, `{imgui_name: "extruder_color_2"}` clicked, Fill, a click at `{spot: "front"}` | as after 11, mmu {2: 2} | |
| 15 | `undo` | as after 11 | |
| 16 | `redo`, then Done | as after 14 | |
| 17 | `project_save` to a new file, `project_new`, `project_open` of the file | as after 14 | `slots()` "0,0"; the object's `enable_support` true and `fuzzy_skin` `none`: painting and the settings it needs are kept in the project file |
| 17 | `project_save` to a new file, `project_new`, `project_open` of the file | as after 14 | `slots()` "0,0"; the object's `enable_support` "1" and `fuzzy_skin` `none`: painting and the settings it needs are kept in the project file |
**Scenario: texture layers**
@@ -191,16 +196,18 @@ starts with it.
| 6 | `Depth` set to 2.5, then idle | z 19.985–22.485 | reply `2.50 mm`; the style combo shows `ITALIC*` |
| 7 | `widget_click {target: {imgui_name: "Revert Depth"}}`, then idle | z 19.985–20.985 | the Depth field reads `1.00 mm`; the style combo shows `ITALIC` |
| 8 | `widget_click {target: {imgui: "Cut"}}`, then idle | negative, z 19.015–20.015 | the text cuts 1 mm into the top |
| 9 | `undo` | part, z 19.985–20.985 | |
| 10 | `redo` | as after 8 | |
| 11 | Done | as after 8 | |
| 12 | `project_save` to a new file, `project_new`, `project_open` of the file | negative "Orca\nMCP", style `ITALIC`, z 19.015–20.015 | |
| 9 | `undo` | negative, z 19.985–20.985 | the Cut takes two undo steps: the gizmo's for the type, then the job's that moves the text inward (`update_volume` in `EmbossJob.cpp`) |
| 10 | `undo` | part, z 19.985–20.985 | |
| 11 | `redo`, `redo` | as after 8 | |
| 12 | Done | as after 8 | |
| 13 | `project_save` to a new file, `project_new`, `project_open` of the file | negative "Orca\nMCP", style `ITALIC`, z 19.015–20.015 | |
**Scenario: SVG**
A 20 mm cube at (100, 100), nothing selected, the camera at `top` and fitted to the objects. `star.svg` is the
fixture `tools/mcp/tests/fixtures/star.svg`, whose star spans 18.6 × 17.6 mm; an SVG is embossed 10 mm deep by
default (`select_shape` in `GLGizmoSVG.cpp`). The panel names the file without its folder and `.svg`.
default (`select_shape` in `GLGizmoSVG.cpp`). The panel names the file without its folder and `.svg`. `svg.path`
is written as the file's name, and checked as the whole path the step gave.
| # | Step | After | Also checked |
|---|---|---|---|
@@ -211,7 +218,7 @@ default (`select_shape` in `GLGizmoSVG.cpp`). The panel names the file without i
| 4 | SVG closed, `object_select {objects: [0]}`, the camera at `top` and fitted to it, `object_add_svg {path: star.svg}`, then idle | the cube has 2 parts: part 1 a part with `svg.path` star.svg, z 19.985–29.985 | `gizmo()` SVG; the part's `bbox` centre lies over the top's square |
| 5 | SVG closed, `undo` | the cube has 1 part | adding the part is one undo step |
| 6 | `redo` | as after 4 | |
| 7 | `project_save` to a new file, `project_new`, `project_open` of the file | as after 4 | both SVG parts keep `svg`, with `path_in_3mf` `3D/star.svg`: the file is stored in the project |
| 7 | `project_save` to a new file, `project_new`, `project_open` of the file | as after 4, but both SVG parts' `svg.path` is `star.svg` alone | both SVG parts keep `svg`, with `path_in_3mf` `3D/star.svg`: the file is stored in the project, and the project names the local file without its folder (`to_xml` in `bbs_3mf.cpp` writes `filename()` unless full paths are exported) |
**Scenario: Measure**
@@ -253,10 +260,9 @@ the camera at `iso` and fitted to it.
|---|---|---|---|
| 0 | start | part 0 `mesh_volume` 8000 · part 1 1000, both type part | the object's `bbox` is x 90–115, y 90–115, z 0–25 |
| 1 | Mesh Boolean opened, `{imgui: "Union", index: 0}` clicked | as after 0 | |
| 2 | `select_source_volume`, a click at `{object: 0, part: 0, spot: "front"}`, `select_tool_volume`, a click at `{object: 0, part: 1, spot: "top"}`, then `{imgui_name: "btn"}`, then idle | one part, type part, its name ending ` - union`, `mesh_volume` 8875 to 1 | the object's `bbox` is x 87.5–112.5, y 87.5–112.5, z -2.5–22.5: the union lands 2.5 mm off along each axis, its bounding-box centre where part 0's centre was, and nothing drops it back onto the bed |
| 2 | `select_source_volume`, a click at `{object: 0, part: 0, spot: "front"}`, `select_tool_volume`, a click at `{object: 0, part: 1, spot: "top"}`, then `{imgui_name: "btn"}`, then idle | one part, type part, its name ending ` - union`, `mesh_volume` 8875 to 1 | the object's `bbox` is x 87.5–112.5, y 87.5–112.5, z -2.5–22.5: the union lands 2.5 mm off along each axis, its bounding-box centre where part 0's centre was, and nothing drops it back onto the bed; `gizmo()` none: with one part left the gizmo can no longer be open (`GLGizmoMeshBoolean::on_is_activable` asks for two), and the manager closes it (`GLGizmosManager::refresh_on_off_state`) |
| 3 | `undo` | as after 0 | the `bbox` as after 0 |
| 4 | `redo` | as after 2 | |
| 5 | Mesh Boolean closed | as after 2 | |
**Scenario: brim ears**
@@ -334,7 +340,7 @@ middle-button drag pans the camera on a new datadir (`middle_mouse_drag_action`
| 10 | the camera at `top` and fitted, `object_select {none: true}`, `mouse_gesture {action: "move", at: {object: 0, part: 1, spot: "top"}}` with the default surface check | not refused | `selection()` is empty: a move selects nothing |
| 11 | `mouse_gesture {at: {object: 0, part: 1, spot: "top"}}` | | `selection()` is [0]: a click on the negative part lands on its object |
| 12 | the camera at `bottom` and fitted, `object_select {none: true}`, `mouse_gesture {at: {object: 0, spot: "bottom"}}` | not refused | `selection()` is [0]: from below the bed hides nothing |
| 13 | `object_select {none: true}`, `mouse_gesture {action: "move", at: {object: 0, part: 1, spot: "top"}}` | refused, its words "is in front of the point" | `selection()` still empty, `scene()` as after 0, and the camera did not move during the step (`app_state.camera` reads as it did after `object_select`): the check runs for a negative part, and from below the cube hides its top |
| 13 | `object_select {none: true}`, `mouse_gesture {action: "move", at: {object: 0, part: 1, spot: "top"}}` | refused, its words "is in front of the point" | `selection()` still empty, the cube and its parts as after 0 and its profile as after 9, and the camera did not move during the step (`app_state.camera` reads as it did after `object_select`): the check runs for a negative part, and from below the cube hides its top |
**To settle in review:**
- Mesh Boolean moves its result (step 2 of its scenario): a bug in the app's own code, which is on `main`, left as
@@ -343,8 +349,7 @@ middle-button drag pans the camera on a new datadir (`middle_mouse_drag_action`
centres the mesh on its bounding box and sets the part's offset to that centre, so the union is still in place; it
then sets the new part's offset to the source part's (`GLGizmoMeshBoolean.cpp:504`), dropping that shift, and the
`ensure_on_bed` call after it is commented out. Step 2 expects where the union lands today: moved by (-2.5, -2.5,
-2.5) mm, from x, y and z 90–115, 90–115 and 0–25 to 87.5–112.5, 87.5–112.5 and -2.5–22.5. The earlier `gizmos.json`
run shows the same shift, its union moved 9.87 mm along y.
-2.5) mm, from x, y and z 90–115, 90–115 and 0–25 to 87.5–112.5, 87.5–112.5 and -2.5–22.5.
- Undo and redo lose a text part's font face name: a bug in the app's own code, on `main`, left as it is.
`FontProp::save` and `load` (`TextConfiguration.hpp`), which undo and redo serialize the style through, leave out
`face_name`, so after an undo `object_list`'s `text.font` gives the style's font descriptor (`style.path`, such as
@@ -354,6 +359,18 @@ middle-button drag pans the camera on a new datadir (`middle_mouse_drag_action`
change the object's setting without an undo step of their own (`GLGizmoFuzzySkin.cpp` and `GLGizmoBrimEars.cpp`
assign the config directly): the app's own code, on `main`, left as it is. The entry expects that, so an undo of
the next step keeps the setting.
- The text's Cut takes two undo steps (text, steps 9 to 11): the app's own code, on `main`, left as it is.
`GLGizmoEmboss::draw_model_type` takes a snapshot and sets the part's type, then starts the job that moves the
text inward, whose `update_volume` (`EmbossJob.cpp`) takes a snapshot of its own. The first undo takes back the
move and leaves the part negative; the second takes back the type.
- The union closes Mesh Boolean (Mesh Boolean, step 2): the app's own code, on `main`. The gizmo can be open only on
an object with more than one part (`GLGizmoMeshBoolean::on_is_activable`), and
`GLGizmosManager::refresh_on_off_state` closes it once the union leaves one, so no step closes it.
- The SVG's file after reopening (SVG, step 7): the project keeps the SVG itself (`path_in_3mf`) and names the local
file by its name alone, `star.svg`, since `to_xml` in `bbs_3mf.cpp` writes `filename()` unless full paths are
exported: the app's own code, on `main`.
- `settings_get` gives a value as the config writes it, so a switch reads "1" or "0" (painting, steps 0 and 17), as
`wall_loops` reads "2".
- The style combo's marker (text, steps 3 to 7): right after the pick the style reads unmodified, since a text
created on the top under the `top` camera has no angle or surface distance of its own (`calc_up` and
`calc_distance` give none for 0), and those are part of the comparison.
@@ -391,7 +408,7 @@ middle-button drag pans the camera on a new datadir (`middle_mouse_drag_action`
- Assembly: point-and-point mode, Flip by Face 2, rotation around the faces' centre and the Parallel button for faces
at an angle.
- Cut: dowel and snap connectors, cutting by groove or contour, flipping or placing the halves, keeping one half,
and the connector's size and depth.
and the connector's size and depth, and so the lower half's height, which its connector part raises above the cut.
- Simplify by error, Mesh Boolean's difference and intersection and their Delete input option, and deleting or
resizing brim ears.
- What the painting, fuzzy skin, brim ears and connectors do to a slice: the test checks what the gizmos leave on the
@@ -402,52 +419,7 @@ middle-button drag pans the camera on a new datadir (`middle_mouse_drag_action`
texture layer row surviving their renames in `test_ref_locator_export`; the Text action opening its gizmo on a new
object in `test_every_action`.
## Replays this area replaces
Each leaves the sweep, with its entry, in the commit that adds the tests above.
### `gizmos`
`tests/gizmos.json` · replay, 251 steps, 92 expects, 1 optional
**Tests:** Every Prepare gizmo driven through the generic GUI tools (gizmo icons, ImGui panel fields, combos and links, clicks and strokes at model points): Move, Rotate, Scale, Flatten, the four painting gizmos, Texture Displacement, Text, SVG, Measure, Simplify, Brim Ears, Mesh Boolean, Assembly (assemble view) and Cut, and what each leaves on the model.
**Decides by:** Fails when a non-optional call errors or an expect misses.
- Open and close: `widget_click {gizmo}` replies `/active` true then false for each gizmo; `app_state /gizmo/name` is "Move" and "SVG" when expected, `/gizmo` null after Move and after Assembly's Return.
- Panel fields: each `widget_set_value` reply `/value` or `/selected` equals the text set ("90.00", "30.00", "120.00", "3.00", "2.50 mm", "60.00", "0.00", "10.00", "ITALIC", "Frustum", "Square", "HarmonyOS Sans SC", "Object"/"World").
- Transforms in `object_list`: Move X `offset/0` 90, undo 100, redo 90; Rotate `rotation_deg/2` > 29.9; Scale `scale/2` > 1.19, undo 1; Flatten `rotation_deg/0` > 89, undo < 1.
- Painting: supports `painted/supports/enforcers` > 0, `painted` gone after undo, `blockers` > 0 after a right-drag; seam `enforcers` > 0, gone after undo; fuzzy skin's link sets the object's `fuzzy_skin` to "none" and `painted/fuzzy_skin` > 0; colour `painted/mmu/2` > 0; texture layer `name` contains "heightmap" and `painted` > 0, a second layer present after `add_layer` and absent after Remove.
- Text and SVG: the text part's `text/text` is "Orca\nMCP" and `text/style` "ITALIC"; after Revert Depth no node reads "2.50 mm"; the SVG object makes `total` 3 with `svg/path` containing star.svg, then star-copy.svg after Save as, star.svg after Change file; a second SVG becomes part 2 of object 0.
- Others: Measure's panel has nodes matching "90.000", "Point on plane" and "Distance"; Simplify closed mid-calculation leaves the app idle (`/satisfied` true) and Apply at 90 % leaves `triangles` < 1000; Brim Ears' link puts `brim_type` in the object's overrides and Auto-generate gives `brim_ears` > 0; Mesh Boolean removes part 2 and undo restores it; Cut makes `total` 4.
- Held press: `mouse_gesture down` replies `/held` true; after a gesture that fails (the optional step), the next move has no `/held`.
**Not checked:**
- Move's alignment cannot fail: both cubes already stand at y 100 with the same size, so `/plates/0/objects/1/instances/0/offset/1` eq 100 is the value before Align front is clicked.
- Undo for Rotate, Fuzzy skin and Color painting: undo and redo run back to back and only the redone value is read, so an undo that does nothing passes.
- Bounds looser than the known value: rotation > 29.9 (30 set), scale > 1.19 (1.2 set), flatten > 89 (90), none with an upper bound; the brim override is checked for the key `brim_type`, not its value.
- Only run, never read back: the font Revert, Rotate's reset to 0 and Scale's to 100, texture "Layer 1", "more" and "close", the brim ear added by a click (the ear count is not read again), Assembly's move apart (only the field reads "60.00") and the face-to-face mate (no object position is read), Cut's connectors (only the combos; the cut is checked by object count, not by connector parts).
- Absence-only text checks: Revert Depth and "The panel shows the new file's name" check only that "2.50 mm" and "star-copy" are not shown; both pass if the panel shows nothing, and the new file name is never looked for.
- Measure's results are matched by text search; I could not confirm whether the "Distance" label appears before any measurement.
- Simplify: the triangle count before is not read, so the < 1000 bound does not show a reduction.
- 17 canvas screenshots are saved and never compared.
- The sweep runs it at 1600×900 only; the 1100×760 run in the header is manual.
**Strength:** Partial — most gizmos' main model edit is read back, but several outcomes (Assembly, Cut connectors, Brim click, Measure) are only run or matched by text, three undos are unverified, and the alignment check cannot fail.
### `dialogs_canvas_input`
`tests/dialogs_canvas_input.json` · replay, 32 steps, 9 expects, 0 optional
**Tests:** That auto-answered "Transfer or discard" prompts on a process preset switch run their buttons' handlers; that a toolbar item a selection just enabled (variable layer height) takes a click at once; and that a negative part, and model points seen from below through the bed, resolve as `mouse_gesture` targets.
**Decides by:** Fails when a call errors (a point that does not resolve or is hidden is refused) or one of its 9 matchers misses.
- Transfer: after `wall_loops` 5 and a switch to the 0.16 mm preset (`/selected` exact), `wall_loops` reads `"5"`.
- Discard: after switching back (`/selected` exact), `wall_loops` `ne "5"` and `app_state /project/dirty` = false.
- Toolbar: `layersediting` click `/pressed` = true, then false.
- Negative part: Text gizmo `/created` = true; after Cut and Done, `object_list` part 1 type = `negative`.
- Canvas targets: the three `mouse_gesture move` steps only have to not be refused.
**Not checked:**
- Discard is read back as `ne "5"`, not as the preset's own value.
- The `mouse_gesture` steps have no expect; the negative-part step turns the visibility check off (`check: point`), so only resolving the part is tested.
- "The text lands on the cube's top" is not checked; only the part's type.
**Strength:** Partial — the auto-answers and toolbar click are read back, but the canvas targets are only "not refused".
**Strength:** Strong — after every step it reads the model back through another tool and compares it with values
written out here, reads every undo before its redo, and checks what a person keeps through the project file; the
counts a brush stroke gives, the Measure distance, the reverted font and where a text or SVG part lands on the top
are checked by a tolerance or a property, as the app works them out.
+47 -145
View File
@@ -3,15 +3,14 @@
The design of this area's sweep tests. The rules every entry follows, the grades and the table of all tests are
in [TESTS.md](../TESTS.md).
Three tests take the place of the six replays of this area. One entry for all six would hold eleven scenarios and
over 130 steps (`test_plates` has 82), and would mix three launches the sweep judges differently:
Three tests, since the sweep judges their launches differently:
- `test_gui_tools` drives the app's own menus, rows, popups and web dialogs with the generic GUI tools
(`context_menus.json`, `rows.json`, `web_dialogs.json`). It runs on the sweep's default launch.
- `test_recording` makes and encodes recordings (`recording.json`). What it can check depends on the machine's
- `test_gui_tools` drives the app's own menus, rows, popups and web dialogs with the generic GUI tools.
It runs on the sweep's default launch.
- `test_recording` makes and encodes recordings. What it can check depends on the machine's
ffmpeg, and it says so in its output, so its verdict is kept apart from the others'.
- `test_call_forms` checks the forms a call takes: the names and values agents send, and a call with exactly an
action's arguments doing what a person's pick does (`agent_forms.json`, `actions_ask.json`). `actions_ask` needs
action's arguments doing what a person's pick does. Part of that needs
the Design tab, so this test launches with it (`"cad": true`), which the other two must not.
Their `sweep.json` entries:
@@ -23,7 +22,7 @@ Their `sweep.json` entries:
```
## `test_gui_tools`
`test_gui_tools.py` · Python · takes the place of `context_menus.json`, `rows.json` and `web_dialogs.json`
`test_gui_tools.py` · Python, 196 checks · in `sweep.json` as `{"path": "test_gui_tools.py"}`
**Tests:** The generic GUI tools on the app's own widgets, as an agent drives any of them: context menus and a
button's menu listed and run by path without being shown, the Edit menu's items, the rows of the object list, of
@@ -86,7 +85,7 @@ Hell`, then `Add Models` and `Show Labels`.
| 16 | `E` with `popup_item: "Add Primitive>Cylinder"` | as after 9, then `Cylinder: Cylinder part` | `app_state.objects` 2 |
| 17 | `widget_click {target: {label: "Add one filament"}}` | as after 16 | `app_state.presets.filaments` has 2 entries |
| 18 | `project_set_settings {values: {filament_colour: "#FF0000;#0000FF"}}` | as after 16 | `colours()` `#FF0000;#0000FF` |
| 19 | `widget_click {target: {label: "Click to edit preset", index: 0}}` | as after 16 | items exactly `Edit`, `Merge with>F2`, `Decompose Color`, `Delete`, where F2 is the filament of slot 2 as the selector names it; `dialogs()` `[]`; `app_state.tab` `prepare` |
| 19 | `widget_click` of filament 1's `Click to edit preset` button, by the ref of the first button of that name `widget_list {target: "main"}` lists with a position and a size | as after 16 | items exactly `Edit`, `Merge with>Bambu PLA Basic`, `Decompose Color`, `Delete`, `Bambu PLA Basic` being the filament of slot 2 as the selector names it; `dialogs()` `[]`; `app_state.tab` `prepare` |
| 20 | the same with `popup_item: "Delete"` | as after 16 | reply `ran` `Delete`; `app_state.presets.filaments` has 1 entry and `colours()` is `#0000FF`: the slot whose button was clicked is the one deleted |
| 21 | `object_select {all: true}`, then `C` | as after 16 | `selection()` objects `[0, 1]` after the select; the items hold `Assemble`, `Align/Distribute>Align left (-X)` and `Delete`, and not `Add Part>Cube`: the menu is the multi-selection's, not one object's |
| 22 | `C` with `popup_item: "Delete"` | none | reply `ran` `Delete`: the multi-selection's Delete removes both objects; `app_state.objects` 0, `closed_menus` `[]`, `dialogs()` `[]` |
@@ -110,7 +109,7 @@ part`, printable, on plate 0.
| 9 | `widget_click {target: {row: "Cube"}, button: "right"}` | `menu()`'s items hold `OBJECT`, `checked` exactly `[Printable, Auto Drop]`: the row's menu is the object's |
| 10 | the same with `popup_item: "Add Modifier>Cylinder"` | reply `ran` `Add Modifier>Cylinder`; `objects()` `Cube: Cube part + Generic-Cylinder modifier` |
| 11 | `widget_click {target: {row: "Cube>Generic-Cylinder"}}` | reply `selected` `["Plate 1>Cube>Generic-Cylinder"]`; `selection()` parts `[[0, 1]]` |
| 12 | `widget_click {target: {row: "Cube>Cube"}, modifiers: ["ctrl"]}` | reply `selected` `["Plate 1>Cube>Cube", "Plate 1>Cube>Generic-Cylinder"]`; `selection()` parts `[[0, 0], [0, 1]]` |
| 12 | `widget_click {target: {row: "Cube>Cube"}, modifiers: ["ctrl"]}` | reply `selected` `["Plate 1>Cube>Cube", "Plate 1>Cube>Generic-Cylinder"]`; `selection()` objects `[0]`, no parts: the two rows select every part of the cube, which the 3D view takes as the whole cube |
| 13 | `widget_click {target: {row: "Cube>Generic-Cylinder"}}` | `selection()` parts `[[0, 1]]`: a right click keeps a selection it is in, so the part is clicked alone first |
| 14 | the same with `button: "right", popup_item: "Change Type>Negative Part"` | reply `ran` `Change Type>Negative Part`; `objects()` `Cube: Cube part + Generic-Cylinder negative` |
| 15 | `widget_click {target: {row: "Plate 1>Cube", column: "Printable"}}` | `objects()` as after 14, not printable |
@@ -183,9 +182,20 @@ Picker"}`; `WIZARD` is `within: "Setup Wizard"`.
- The empty space's menu `DEFAULT` (menus, step 12), from `create_default_menu()` and `handy_models()` in
`GUI_Factories.cpp`, with labels off on a new datadir. Writing it whole makes a new handy model a change to this
entry.
- `Click to edit preset` at index 0 is filament 1's button on every platform (menus, step 19): the printer's button of
that name is hidden until the pointer is over its panel. Its menu is `create_filament_action_menu()`'s, and its
`Delete` is enabled on the X1 Carbon, which shows the multi-material buttons.
- Filament 1's `Click to edit preset` button (menus, step 19) is the first of that name with a position and a size in
`widget_list`. The printer's button of that name comes first in the listing but is hidden until the pointer is over
its panel, and on Windows and macOS `{label: "Click to edit preset", index: 0}` still names it, as the locator's
index counts it (its menu is `Edit preset` and `Add/Remove presets`); only on Linux is index 0 filament 1's. So the test names the button by the ref of the first one shown. Its menu is
`create_filament_action_menu()`'s, and its `Delete` is enabled on the X1 Carbon, which shows the multi-material
buttons.
- A call that opens a dialog the start's rules answer (the Add Cube action's size dialog, Add Modifier's tip) is
followed to its end through that dialog, not judged by its first reply: under load the reply is at times
`blocked_by_dialog` for a dialog whose rule has queued its press but not yet made it. The test passes with or
without that; a reply that waits on a dialog no rule answers still fails the call after 60 s.
- Two part rows that select every part of the object (rows, step 12) make the 3D view's selection the whole object:
`Selection::update_type()` switches to the instance mode when every part of the one instance is selected (on
`main` since 1555904beff), and `app_state.selection` lists `parts` only for a selection of parts. So `selection()`
reads objects `[0]` with no parts, while the reply's `selected` lists both rows.
- A plate whose only object is not printable slices to `empty` (rows, step 16): `classify_plates()` gives `empty` to a
plate without printable instances. If the slice is refused instead, the step asserts that refusal's code.
- Compare presets (dialog rows, steps 2 to 4): the row value `0.2 | 0.12` (the cells after the label, joined) and the
@@ -235,8 +245,11 @@ Picker"}`; `WIZARD` is `within: "Setup Wizard"`.
is checked.
- How menus, rows and dialogs look: nothing is shown or captured.
**Strength:** Strong — every menu item, row and page element it runs is checked by its effect on the project, the
selection, the camera or the settings; only the spectrum drag's colour is checked as another valid colour.
## `test_recording`
`test_recording.py` · Python · takes the place of `recording.json`
`test_recording.py` · Python, 110 checks with an ffmpeg that has libx265 and libx264 · in `sweep.json` as `{"path": "test_recording.py"}`
**Tests:** `recording_start`, `recording_stop` and `recording_encode`: a recording made while the GUI is driven, its
report and its file; a recording a nested `replay_run` starts and never stops, which the replay's end closes;
@@ -262,8 +275,8 @@ something that is not a file, that `ORCA_FFMPEG` names it. An encode asked for a
only when ffmpeg is missing; with ffmpeg but not the encoder, the start and stop succeed and the encode job ends
with the encoder's error. A refusal or an error is checked like any other result, and the file checks the encode
would have had are printed as `SKIP <check>: <why>`, never passed silently. The test's last line names what it could
encode: `encodes checked: h265 yes, h264 no (ffmpeg has no libx264)`. The `Checks` module gains `skip(name, why)`
for this; see **To settle**.
encode: `encodes checked: h265 yes, h264 no (ffmpeg has no libx264)`. The test's checks gain `skip(name, why)` for
this, in a subclass of `Checks` the test holds; see **To settle**.
**Scenario: a recording while the GUI is driven**
@@ -276,9 +289,9 @@ for this; see **To settle**.
| 3 | `mouse_gesture {action: "click", x: 300, y: 200}` | `app_state.selection` empty: a click on empty space deselects |
| 4 | `mouse_gesture {action: "click", at: {object: 0, spot: "top"}}` | `app_state.selection` objects `[0]` |
| 5 | `widget_set_value {target: {label: "Process"}, value: false}`, then `widget_set_value {target: {option: "layer_height"}, value: "0.16"}` | `settings_get` of the process gives `layer_height` `"0.16"` |
| 6 | `keyboard_press {target: {option: "initial_layer_print_height"}, keys: "ctrl+a", text: "0.24"}`, then `keys: "Return"` | `initial_layer_print_height` `"0.24"` |
| 6 | `keyboard_press {target: {option: "initial_layer_print_height"}, keys: "ctrl+a", text: "0.24"}`, then `keys: "Return"` | the first reply is exactly `{sent: "ctrl+a", to: "TextInput", typed: "0.24"}`; `initial_layer_print_height` stays `"0.2"`: typed keys reach ImGui fields and key handlers, not a native text field |
| 7 | `action_run` Preferences, then `dialog_answer {dialog: {title: "Preferences"}, button: "close"}` | the first replied `blocked_by_dialog` with `Preferences`; its job ends without an error; `app_state.dialogs` `[]` |
| 8 | `plate_slice`, then `project_export {path: OUT/session.gcode, overwrite: true}` | plate 0's outcome `ok`; the G-code's config block holds `; layer_height = 0.16` and `; initial_layer_print_height = 0.24`, and its first two distinct `; Z_HEIGHT:` values are 0.24 and 0.4: the values typed shaped the layers printed |
| 8 | `plate_slice`, then `project_export {path: OUT/session.gcode, overwrite: true}` | plate 0's outcome `ok`; the G-code's config block holds `; layer_height = 0.16` and `; initial_layer_print_height = 0.2`, and its first two distinct `; Z_HEIGHT:` values are 0.2 and 0.36: the value set shaped the layers printed, and the keys typed did not |
| 9 | `recording_stop {silent: true}` | reply `ended` `stopped`, `path` `OUT/session.mkv`, `frames` and `written` at least 5, `failed` 0, `seconds` above 1, `capture_ms` above 0, `width` and `height` `MAIN`, `size_bytes` the file's size; `recording()` none. `mkv()`: codec `V_MJPEG`, `MAIN`, default frame duration 100 ms, `written` blocks or one more (the last frame held to the end), duration within 0.1 s of `seconds` |
| 10 | `recording_encode {save_path: OUT/session.mp4, overwrite: true, keep_raw_video_file: true}` | with libx265: reply `path` `OUT/session.mp4`, `source` `OUT/session.mkv`, `codec` `h265`, `encoder` `libx265`, `raw_video_file_deleted` false, `size_bytes` the file's size; `mp4()`: `hvc1`, duration within 0.3 s of step 9's `seconds`; `OUT/session.mkv` is still there. Without: refused as above; no `OUT/session.mp4`, and `OUT/session.mkv` is still there |
@@ -326,7 +339,13 @@ The default limit of an hour is step 1 of the first scenario (`max_seconds` 3600
counts it, and `run_sweep.py` adds the count of a passing test's `SKIP` lines to its result line (`passed, 9
skipped`), so a sweep on a machine without ffmpeg says so without reading the log. The other choice is an
environment variable that turns the encode `SKIP`s into failures on a machine that must have ffmpeg. Either is a
change to the harness, not to the app.
change to the harness, not to the app. Until it is settled, `skip()` lives in the test's own subclass of `Checks`,
and a skipped check is not counted among the checks.
- Typed keys leave a setting's field as it was (first scenario, step 6): `keyboard_press` sends key events to the
field's `TextInput`, which a native text control does not take as typing; its description says typing reaches
ImGui fields and key handlers and sends a widget's text field to `widget_set_value` (`McpToolsUi.cpp`, this
branch's d64e10f4dd). The step stays as the recording's typed caption, and step 8 shows that the first layer kept
its 0.2 mm while the layer height set by `widget_set_value` took effect.
- A recording's first frame is the size `window_screenshot` captures of the same target (`MAIN`, `CANVAS`): both
capture the window, or the 3D view, in physical pixels; the recorder then fits the capture with `video_size()`.
- The file holds `written` blocks or one more (first scenario, step 9): closing the sink writes the last frame again
@@ -354,9 +373,12 @@ The default limit of an hour is step 1 of the first scenario (`max_seconds` 3600
- `job_cancel` of an encode, a write error and the size limit: the sink's unit tests cover write errors.
- A recording ending when a script ends or the server is turned off: only a replay's end is tested.
**Strength:** Strong — each recording's report is checked against its file, and each encode against its MP4, where an
ffmpeg with the encoder is present; frame counts and capture times have lower bounds, and the frames' pixels are left
to the unit tests.
## `test_call_forms`
`test_call_forms.py` · Python, launched with the Design tab (`"cad": true`) · takes the place of `agent_forms.json`
and `actions_ask.json`
`test_call_forms.py` · Python, 94 checks · in `sweep.json` as `{"path": "test_call_forms.py", "cad": true}`
**Tests:** The forms a call takes. Names and value shapes agents send in place of the schema's (a lone path for
`paths`, `object` and a string index for `objects`, `action` and an action's short name for `id`, a camera direction
@@ -394,11 +416,11 @@ current. `CUBE` is `resources/handy_models/OrcaCube_v2.drc`; `OUT` is the test's
| 12 | `object_select {objects: [0]}`, then `widget_click {target: {gizmo: "Support Painting"}}` | `selection()` objects `[0]` after the select; reply `gizmo` `FdmSupports`, `active` true; `app_state.gizmo.name` `FdmSupports` |
| 13 | `widget_click {target: {gizmo: "support painting"}}` | reply `active` false; `app_state.gizmo` null |
| 14 | `object_arrange {plate: "0"}` | both objects on plate 0, their `bbox` footprints apart and inside plate 0's rectangle (`origin` and `size` from `plate_list`) |
| 15 | `plate_slice {plate: "0"}` | reply `plates` `[{index: 0, outcome: ok}]`; `plate_list` gives plate 0 `sliced` true |
| 15 | `plate_slice {plate: "0"}` | reply `plates` is one plate, its `index` 0 and `outcome` `ok`; `plate_list` gives plate 0 `sliced` true |
| 16 | `view_set {tab: "preview", legend: {sparse_infill: false, Travel: false, "Prime tower": false, Pauses: false}}` | reply `legend` exactly `{"Sparse infill": false, "travel": false}`: rows this print lacks are left out, not refused; `legend()` gives `features["Sparse infill"]` false and `options["travel"]` false |
| 17 | `view_set {legend: {"Sparse infill": true, travel: true}}` | `legend()` gives both true |
| 18 | `view_set {tab: "prepare"}`, then `project_export {path: OUT/forms.gcode, overwrite: true}` | `app_state.tab` `prepare`; reply `export` `ok`; the file starts with `; HEADER_BLOCK_START`: the format came from the path |
| 19 | `project_export {path: OUT/forms.stl, overwrite: true}` | reply `objects` `[0, 1]` and `bytes` the file's size; `stl()`: its triangle count is the sum of the two objects' parts' `triangles` from `object_list`, and its size 84 + 50 × that count |
| 19 | `project_export {path: OUT/forms.stl, overwrite: true}` | reply `objects` lists objects 0 and 1, by their `index`, and `bytes` is the file's size; `stl()`: its triangle count is the sum of the two objects' parts' `triangles` from `object_list`, and its size 84 + 50 × that count |
| 20 | `settings_list {type: "process", limit: 5}` | 5 items, each with a `value` and none with `meta` |
| 21 | `settings_get {type: "process", keys: ["wall_loops"]}` | `items[0].meta.type` `int` |
@@ -440,8 +462,7 @@ is checked: `objects()` is one object, on plate 0, `bbox.size` `[20, 20, 20]` to
- The Design tab's camera is its own (shown view, step 4): `test_set_view_camera` finds the Design zoom apart from
the Prepare view's, so View: Top there leaves the Prepare view's elevation at 0.
- A new project is named `Untitled` (dialog, start and step 2), the name the Plater gives a project without a file.
- The temperature dialog's Cancel ends its job without an error (dialog, step 2), as the replay's wait on the job
passes today; the reply's fields are not fixed.
- The temperature dialog's Cancel ends its job without an error (dialog, step 2); the reply's fields are not fixed.
- Deselect All closes the open gizmo (shown view, step 6), as `object_select`'s description says of `none`, which the
action's arguments are.
- The 20 mm object slices to 100 layers at the X1 Carbon's 0.2 mm first and other layers, and Go to layer 50 % shows
@@ -460,124 +481,5 @@ is checked: `objects()` is one object, on plate 0, `bbox.size` `[20, 20, 20]` to
- Deselect All while the Design tab or the assemble view is shown.
- The G-code's content beyond its first line: names, step 18, checks only which format the path chose.
## Replays this area replaces
Each leaves the sweep, with its entry, in the commit that adds the tests above.
### `context_menus`
`tests/context_menus.json` · replay, 34 steps, 19 expects, 0 optional
**Tests:** Context and button menus listed or run by path (`mouse_gesture`/`widget_click` with `popup_item`) without ever being shown: the object menu on a cube, the empty-bed menu, a preset edit button's menu, the multi-selection menu, and the Edit menu's Undo and Redo picked as `Edit>Undo`/`Edit>Redo`.
**Decides by:** Fails when a call errors or one of its 22 matchers misses.
- Object menu: the listing contains `Add Modifier>Cylinder` and checked contains `Printable`; running it gives `/ran` = the path and an `object_list` part 1 of type `modifier`; undo removes it and redo restores it, both through the action and the Edit menu items (`/clicked` = path).
- Empty bed: the listing contains `Add Primitive>Cube`; running `Add Primitive>Cylinder` leaves `app_state /objects` = 2.
- Button menu: `Click to edit preset` index 0 gives a non-empty `/popup_menu/items`; no dialog open, tab still `prepare`.
- Multi-selection: the listing contains `Align/Distribute>Align left (-X)` and `Delete`; running `Delete` leaves 0 objects and `closed_menus` empty.
**Not checked:**
- The button menu is checked only as non-empty; which button's menu opened and what it lists are not.
- Each listing is matched by one known item (`contains`); missing or wrong other items pass.
- `widget_click {label: "Add one filament"}` has no expect (it matters only on Linux).
**Strength:** Strong — every item run is checked by its effect on the model, and every listing by a known item.
### `rows`
`tests/rows.json` · replay, 54 steps, 28 expects, 0 optional
**Tests:** Rows of lists, trees and tables as `widget_click` targets and popups as `widget_list` roots: object list plate, object and part rows (Ctrl-click, the Printable column, a double click), menus run from rows, Compare presets' data view rows, the object settings table, the print button's popup, and the plate-type drop-down list.
**Decides by:** Fails when a call errors or one of its 30 matchers misses.
- Plate rows: `/selected` = `["Plate 2"]` and `app_state` current plate 1, then back to 0.
- Object and part rows: `/selected` exact for a click and a Ctrl-click; row menus list and run `Add Modifier>Cylinder` and `Change Type>Negative Part`, read back as part types in `object_list`.
- Printable column: `printable` false, then true; the double click's `/selected` exact.
- Compare presets: `/clicked` contains the `Quality>Layer height>Layer height` path.
- Parameter table: the dialog opens, lists one `Generic-Cylinder` node, a `Wall loops` cell click returns `/column` = `Wall loops`, and `dialog_answer` closes it.
- Print button popup: exactly one "Export plate sliced file" node in the popup, none after the pick, one on the main window.
- Drop-down: ≥ 2 rows; picking `Textured PEI Plate` gives `/clicked` exact and one main-window node with that text; set back, one with "Smooth Cool Plate"; no dialog open, no unseen menu.
**Not checked:**
- Compare presets: the second preset (`widget_set_value` index 5) has no expect, neither preset's values are read, and Escape closing it is not checked (the final `/dialogs` check lists modal dialogs only; Compare presets is modeless).
- The parameter table being read-only is not tested; only a cell click.
- The double click's framing of the object is not checked.
- The plate type is checked by counting widgets with its text, not by reading `curr_bed_type`.
**Strength:** Partial — tree rows and their menus are checked by effect, but the Compare presets and table sections mostly check that the click resolved.
### `web_dialogs`
`tests/web_dialogs.json` · replay, 30 steps, 17 expects, 0 optional
**Tests:** Orca's own web dialogs driven only through the generic GUI tools: the preset bundle dialog closed by its page's button; the colour picker behind a filament swatch's "+ More Colors" (hex field set, spectrum canvas dragged, colour returned to the native Select Filament dialog); and the setup wizard's first steps (a region, Next, a printer card).
**Decides by:** Fails when a call errors or one of its 19 matchers misses.
- Preset bundle: the dialog opens, its page lists > 2 nodes, `#close_btn` gives `/closed` = true, the job ends, no dialog left.
- Colour picker: hex `FF0000` reads back `/value` = `FF0000FF` and is listed; the drag gives `/done` = `drag`, after which nothing reads `FF0000FF`; OK gives `/closed` = true with "Select Filament" on top; then no node reads `#26A69A`; Select Filament is cancelled and no dialog is left.
- Wizard: `Europe` `/checked` = true; Next `/navigated` = true with URL containing `/guide/21/`; the printer card `/checked` = true; closed, no dialog left.
**Not checked:**
- The colour returned to Select Filament is never read; the only check is that `#26A69A` is absent, and no step shows that text was listed before (the preview label may show a colour name instead), so it may pass whatever comes back.
- After the drag, `FF0000FF` being absent passes for any change of the hex field.
- Closing the wizard is not checked to leave the region and printer choice unapplied, nor cancelling Select Filament to leave slot 1's colour unchanged.
**Strength:** Partial — each control's own reply is checked, but the colour round trip's result is not.
### `recording`
`tests/recording.json` · replay, 42 steps, 28 expects, 11 optional
**Tests:** `recording_start`, `recording_stop` and `recording_encode`: a recording made while the GUI is driven (clicks, a typed setting, the Preferences dialog, a slice), stopped and encoded to H.265; a recording a nested `replay_run` starts and never stops, which that replay's end closes, encoded to H.264; overlay defaults (`captions`, `pointer`); the one-hour default limit; and encoding asked for at start, run as a job on stop, deleting or keeping the `.mkv`.
**Decides by:** Fails when a non-optional call errors or a non-optional step's matcher misses.
- Start: `/width` ≥ 320, `/fps` = 10, `captions`/`pointer` as asked; `app_state /recording/path` ends in `session.mkv`.
- Stop: `/ended` = `stopped`; `frames` and `written` ≥ 5; `seconds` > 1; `size_bytes` and `capture_ms` > 0; `app_state` then has no `/recording`.
- Nested replay: `/passed` = true with no `unfinished_recording`; the next stop reports `/ended` = `run_ended` for `inner.mkv`; recording to that path again starts at once.
- Overlays and limit: without flags both are false; each flag turns on only its own overlay; `/max_seconds` = 3600.
**Not checked:**
- Every encode step is optional (both `recording_encode` calls and all nine steps of the encode-on-stop section), so H.265/H.264 encoding, the encode job, and deleting or keeping the `.mkv` can fail without failing the test, with or without ffmpeg.
- Captions and pointer are checked only as flags in the start reply; no frame is inspected.
- The driven GUI steps (`mouse_gesture`, `widget_set_value` layer height 0.16, `keyboard_press` 0.24) have no expect, and the settings are never read back.
- Frame counts, duration and size are lower bounds only.
**Strength:** Partial — start, stop and the replay-owned recording are checked, but encoding is entirely optional.
### `agent_forms`
`tests/agent_forms.json` · replay, 27 steps, 17 expects, 0 optional
**Tests:** The argument normaliser: names and value shapes agents send in place of the schema's (a lone path for `paths`, `object` with a string index, `action` for `id`, an action by its short name, `canvas` for a camera direction, `position`, `key`, `plate` as a string, legend rows in another case or with `_`, a gizmo by its toolbar title in any case, `app_wait` with no condition, `project_export` without `format`), and `settings_list` leaving meta out of a whole listing.
**Decides by:** Fails when a call errors (the schemas are closed, so an alias that stopped working is an "unknown argument" error) or one of its 25 matchers misses.
- Objects: both `project_import` forms `/added` = 1; after `object_select {object: "1"}` and `object_rename`, object 1 is named "renamed" and object 0 is not; `object_transform {position}` lands at offset 100 ± 0.01, 110 ± 0.01.
- Actions and camera: `action_run {action: "view_top"}` `/ran` = `orca_command:view_top:orca`; `view_set {canvas: "front"}` `/camera` = `front`; `app_wait {}` `/satisfied` = true.
- Gizmo: `{gizmo: "Support Painting"}` opens `FdmSupports` (reply `/gizmo`, `/active`, and `app_state /gizmo/name`); the lower-case title closes it (`/active` = false).
- Slice and export: `plate_slice {plate: "0"}` outcome `ok`; the `.gcode` export without `format` `/export` = `ok`.
- Legend: `/legend/Sparse infill` and `/legend/travel` = false after hiding them as `sparse_infill` and `Travel`.
- Settings: `settings_list` `/items/0/value` exists and `/items/0/meta` does not; `settings_get` `/items/0/meta/type` exists.
**Not checked:**
- `object_select {object: "1"}`: the second import leaves object 1 selected already, so the rename check passes even if the select does nothing.
- `keyboard_press {key: "Escape"}` and `object_arrange {plate: "0"}` are accepted but their effect is never read.
- The `.stl` export has no expect; the format inferred from the path is not read from the reply or the file.
- `/legend/Prime tower` `exists: false` cannot fail: the reply lists only rows this single-colour print has. `Pauses` is not read at all.
- The second legend `view_set` (rows shown again) reads back `Sparse infill` only, not `travel`.
**Strength:** Partial — most forms are proven by a read-back, but `key`, `plate` for arrange and the STL format are only accepted, not checked for effect.
### `actions_ask`
`tests/actions_ask.json` · replay, 33 steps, 19 expects, 0 optional
**Tests:** That a call with exactly an action's arguments does what a person's pick does (run with the Design tab on): `calibration_generate_test {test}` opens the test's dialog while `silent` runs with defaults; View: Top turns the Design tab's camera; Deselect All clears the shown view's selection; Go to tab and Go to layer take their value through `action_run`; `plate_slice {preview: true}` and Slice and Preview slice and switch to the Preview.
**Decides by:** Fails when a call errors or one of its 32 matchers misses.
- Asking: the un-awaited `calibration_generate_test {test: temperature}` returns `/status` = `blocked_by_dialog`; `dialog_answer` must find "Temperature calibration"; the job must end without error.
- Silent: `/test` = `temperature`; `object_list` `/total` ≥ 1.
- Design camera: `view_set` front gives `/camera_state/elevation` in [-5, 5]; `view_top` `/ran` = full id with elevation ≥ 85, and `app_state` shows tab `design` and elevation ≥ 85.
- Deselect All: `object_select` `/objects` = [0]; `deselect_all` `/empty` = true, `/canvas` = `3d`; `app_state /selection/empty` = true.
- Go to: `/tab` = `preview` in the reply and `app_state`; after `go_to_layer {percent: 50}`, `plate_slice_stats` `/view/layer_count` in [90, 110] and `/view/layers/1` in [45, 56].
- Slice actions: `/status` = `done`, outcome `ok`, and `app_state /tab` = `preview`, for both.
**Not checked:**
- Cancel in the temperature dialog: nothing checks that no test model was added or presets changed (the next step replaces the project anyway).
- The silent run's model is checked as `/total ge 1` and a name that `exists`; the known single `temperature_tower.drc` is not compared.
- `layer_count` 90–110 is looser than the known 100 layers of a 20 mm cube at 0.2 mm.
**Strength:** Partial — each action's main effect is read back, but the Cancel path and the silent run's model are not.
**Strength:** Strong — each form is shown by what the call did to the project, the view or the reply, not by the call
going through.
+58 -196
View File
@@ -3,29 +3,12 @@
The design of this area's sweep tests. The rules every entry follows, the grades and the table of all tests are
in [TESTS.md](../TESTS.md).
Two tests take the place of the object replays. One entry would hold seventeen scenarios and some 190 steps, more
than one review can check value by value against the code. They split where their checks do: `test_objects` measures
where objects stand and how many there are (places in mm, instances, arrangements, the print's copies), and
`test_object_structure` reads what objects are made of and how the list orders them (parts and their types, names,
order, meshes and the files they come from). What each replaced replay checks goes to these tests as follows:
| Replay | Where its checks go |
|---|---|
| `menu_items_objects.json` | instances and Set as Individual Objects: `test_objects`, the number of instances; rename, delete and the layer commands on the selection: `test_object_structure`, renaming and deleting |
| `menu_items_placement.json` | `test_objects`: adding a shape; placing objects |
| `menu_items_structure.json` | `test_object_structure`: splitting and assembling; ordering |
| `objects_state.json` | Printable: `test_objects`, leaving instances out of the print; Auto Drop: `test_objects`, moving an instance; Fix Model: `test_object_structure`, repairing a mesh |
| `objects_order.json` | `test_object_structure`: ordering |
| `objects_files.json` | Clone: `test_objects`, cloning; Reload from disk, Replace 3D file and keep_painting: `test_object_structure`, files a part comes from, and painting kept through a mesh change |
| `scene.json` | instance and part moves, the selection, Mirror, shapes, Arrange and Fill bed, instances: `test_objects`; `part_add`, Change Type, Rename, Assemble, Order By: `test_object_structure` |
| `ops_set_instance_count.json` (removed) | `test_objects`, the number of instances |
| `ops_start_arrange.json` (removed) | `test_objects`, arranging and filling the bed |
Two tests, split where their checks do: `test_objects` measures where objects stand and how many there are (places in
mm, instances, arrangements, the print's copies), and `test_object_structure` reads what objects are made of and how
the list orders them (parts and their types, names, order, meshes and the files they come from).
## `test_objects`
`test_objects.py` · Python · takes the place of `menu_items_placement.json`, and with `test_object_structure` of
`menu_items_objects.json`, `objects_state.json`, `objects_files.json` and `scene.json`; covers what the removed
`ops_set_instance_count.json` and `ops_start_arrange.json` recorded · in `sweep.json` as
`{"path": "test_objects.py"}`
`test_objects.py` · Python, 534 checks · in `sweep.json` as `{"path": "test_objects.py"}`
**Tests:** Where objects stand and how many there are: adding a shape at a size, a place, a plate and a name; moving,
turning and scaling an instance, moving it to another plate, and what Auto Drop does to a move; moving and scaling a
@@ -36,10 +19,8 @@ default printer, the Bambu Lab X1 Carbon 0.4: a bed 256 mm square and 250 mm hig
18 × 28 mm at its front left corner (`bed_exclude_area`), and plates laid out 307.2 mm apart (the bed and a fifth of
it), two to a row.
**Files:** The test writes into a folder of its own, `W` (`tempfile.mkdtemp()`), the project it saves and the G-code
files it exports. It does not use `tests/fixtures/objects_files.py`, which leaves with `objects_state.json` and
`objects_files.json`; `tests/fixtures/ops_undo.py` stays for `test_menu_items_refusals.py`. Undo steps are counted by
undoing them and reading the state back, not from the log.
**Files:** The test writes into a folder of its own, `W` (a `tempfile.TemporaryDirectory()`, removed when the test
ends), the project it saves and the G-code files it exports. Undo steps are counted by undoing them and reading the state back, not from the log.
**Reads:** `plates()` as `test_plates` reads it. New readers in `checks.py`:
- `scene()`: each object of `object_list` in index order, its entry whole (`name`, `id`, `filament`, `auto_drop`,
@@ -55,8 +36,8 @@ undoing them and reading the state back, not from the log.
order they first print, each with the number of different `id`, `copy` pairs printed under it: its copies
(`gcode_label_objects` is on in the X1C's process).
- Geometry on `bbox`: an instance's square is its `bbox` in x and y; two squares are apart when they do not overlap;
a square is inside plate p when it lies within `rect(p)`; the gap between two squares is their distance along the
axis on which they are apart.
a square is inside plate p when it lies within `rect(p)`; the gap between two squares is the distance between
them: along the axis on which they are apart, corner to corner when they are apart on both.
Every scenario starts with `project_new {discard_changes: true}` in the Prepare view and checks that `plates()` is
`"" 0 *` and that there are no objects; a `project_new` within a scenario is followed by the same check.
@@ -136,7 +117,7 @@ every step the objects are base@0 · single@0, base at +(100, 100) (but in step
| 14 | `object_select {objects: [0]}` | as after 9 | the reply's `objects` `[0]` and `instances` `[[0, 0]]` and no `parts`: a whole instance lists none; `selection()` the same |
| 15 | `object_mirror {parts: [[0, 1]], axis: "x"}` | `mirrored` true, at +(110, 100, 15) | the reply names part 1 of base; a part mirrors in its place; base's instance not mirrored. From here part 1's `rotation_deg` is not compared (see Not checked) |
| 16 | `object_mirror {objects: [0], axis: "x"}` | at +(90, 100, 15) | base's instance `mirrored` true; an instance mirrors about the centre of the selection's box, here x 100, as part 1 lies within the cube's width: part 1 goes to the other side and part 0 stays at +(100, 100, 5); single not mirrored |
| 17 | `object_mirror {objects: [0], axis: "y"}` | at +(90, 100, 15) | base's instance `mirrored` false: a mirror along X and one along Y make a half turn; the box's centre is y 100, so the places stay |
| 17 | `object_mirror {objects: [0], axis: "y"}` | at +(90, 100, 15) | base's instance `mirrored` false and `rotation_deg` `[0, 0, 180]`: a mirror along X and one along Y make a half turn; the box's centre is y 100, so the places stay |
| 18 | `object_select {none: true}`, then `object_mirror {axis: "x"}` | as after 17 | refused, `nothing_selected`; base's instance and single not mirrored, part 1 `mirrored` true |
**Scenario: the number of instances**
@@ -169,7 +150,7 @@ every step but these: `"" 3 *` after 18 and 20, and `"" 5 *` after 21.
| 19 | `undo` | a@0×4 · b@0×2 | Set as Individual Objects was one undo step |
| 20 | `object_separate_instances {instances: [[0, 3]]}` | a@0×3 · b@0×2 · a@0 | the reply's `objects` names a at 2; object 2 at +(98.4, 98.4), where the instance stood |
| 21 | `object_select {objects: [0]}`, then `object_separate_instances {}` | a@0 · b@0×2 · a@0 · a@0 · a@0 | the reply's `objects` names a at 0, 3 and 4; a at +(60, 60), object 3 at +(85.6, 85.6), object 4 at +(72.8, 72.8): each instance but the first becomes an object, the last instance first |
| 22 | `project_new`, a 20 mm cube named cut, cut in two with a connector through the Cut gizmo (as `test_menu_items_refusals` cuts it), then `object_set_instances {object: 0, count: 2}` | cut_A@0 · cut_B@0, in either order | refused, `cut_object`; each half one instance; `plates()` `"" 2 *` |
| 22 | `project_new`, a 20 mm cube named cut, cut in two with a connector through the Cut gizmo (as `test_menu_items_refusals` cuts it), then `object_set_instances {object: 0, count: 2}` | cut@0 · cut@0 | refused, `cut_object`; each half one instance; `plates()` `"" 2 *` |
**Scenario: placing objects**
@@ -262,7 +243,7 @@ opening a project makes plate 0 current.
| # | Step | Objects after | Also checked |
|---|---|---|---|
| 1 | `plate_add`; kept, a 20 mm cube at `plate: 0`, `position: corner(0) + (60, 60, 0)`; `object_set_instances {object: 0, count: 2}`; `object_transform {object: 0, instance: 0, rotate: [0, 0, 30], mode: "absolute"}`; `object_transform {object: 0, instance: 1, scale: 1.5}`; `object_mirror {instances: [[0, 1]], axis: "x"}`; `object_set_printable {instances: [[0, 1]], printable: false}` | kept@0×2 | instance 0 at +(60, 60), `rotation_deg` `[0, 0, 30]`; instance 1 at +(72.8, 72.8), `scale` `[1.5, 1.5, 1.5]`, `mirrored` true, `printable` false. From here instance 1's `rotation_deg` is not compared (see Not checked) |
| 1 | `plate_add`; kept, a 20 mm cube at `plate: 0`, `position: corner(0) + (60, 60, 0)`; `object_set_instances {object: 0, count: 2}`; `object_transform {object: 0, instance: 0, rotate: [0, 0, 30], mode: "absolute"}`; `object_transform {object: 0, instance: 1, scale: 1.5}`; `object_select {instances: [[0, 1]]}`, then `object_mirror {axis: "x"}`; `object_set_printable {instances: [[0, 1]], printable: false}` | kept@0×2 | instance 0 at +(60, 60), `mirrored` true, turned 30 degrees: `bbox.size` `[27.32, 27.32, 20]` to 0.01; instance 1 at +(72.8, 72.8), `scale` `[1.5, 1.5, 1.5]`, `mirrored` true, `printable` false: Mirror of the selected instance mirrors the object's other instance with it. From here instance 0's `rotation_deg` is not compared (see Not checked) |
| 2 | lifted, a 20 mm cube at `plate: 1`, `position: corner(1) + (60, 60, 0)`; `object_set_auto_drop {objects: [1], auto_drop: false}`; `object_transform {object: 1, translate: [0, 0, 15]}` | kept@0×2 · lifted@1 | lifted at +(60, 60), `auto_drop` false, `bbox.min` z 15 |
| 3 | `project_save` to a new file in `W`, `project_new`, then `project_open` of the file | as after 2 | every value as after 2: the places, turns, scales, mirrors, printable flags and Auto Drop of the instances are kept in the project file |
@@ -284,8 +265,16 @@ opening a project makes plate 0 current.
- An object lifted with Auto Drop off reopens where it was saved, 15 mm above the bed (what the project keeps,
step 3): the project file stores `auto_drop`, and opening a project puts its objects on the bed through
`ModelObject::ensure_on_bed()`, which leaves an object with Auto Drop off where it is.
- The rotation Auto-Orient gives a cube on its edge (placing, step 14): x 90, the value `menu_items_placement.json`
passes with. That it lies on a face, z 20, holds whichever face it picks.
- The rotation Auto-Orient gives a cube on its edge (placing, step 14): x 90. That it lies on a face, z 20, holds whichever face it picks.
- Mirror of one instance (what the project keeps, step 1). `object_mirror` names objects and parts, and mirrors one
instance as Mirror does, on the selection. The app's Mirror mirrors the other instances of the selected instance's
object with it (`Selection::scale_and_translate()` synchronises the unselected instances, the app's own code), so
both of kept's instances are mirrored.
- The names of a cut's halves (instances, step 22): a cut by a plane names both halves after the object
(`Cut::perform_with_plane()`, the app's own code); only a cut along a contour or with a groove adds `_A` and `_B`.
- A scale that grows instance 1 (what the project keeps, step 1) leaves it resting on the bed: `object_transform`
drops the instance it moved by that instance's own lowest point, as the Scale gizmo drops what it scaled
(`GLCanvas3D::do_scale()`), not by instance 0's, which `ModelObject::ensure_on_bed()` measures.
**Not checked:**
- A person's pick of the Speed Dial actions of these commands (Center, Drop to Bed, Scale to Fit, Auto-Orient,
@@ -295,8 +284,7 @@ opening a project makes plate 0 current.
reads their results whole, the Auto-Orient rotations among them. The Set Number of Instances action is run here only
to show its dialog cancelled.
- Auto-Arrange's reply, journal step and replay against its action, and `object_select {all: true}`:
`test_person_forms`. An arrange from the assemble view and with the Move gizmo open, which `ops_start_arrange.json`
recorded: `test_operation_routes`. What a lock does to Arrange and Auto-Orient: `test_plates`.
`test_person_forms`. An arrange from the assemble view and with the Move gizmo open: `test_operation_routes`. What a lock does to Arrange and Auto-Orient: `test_plates`.
- The refusals `test_menu_items_refusals` checks with the state after them: Set as Individual Objects on an object of
one instance, Add Primitive's pick with an object selected, `object_mirror` with no axis,
`object_center` and `object_add_primitive` on a plate the project lacks, a pick of Mirror with two objects selected,
@@ -306,12 +294,14 @@ opening a project makes plate 0 current.
- Fill bed with copies (`fill_with: "copies"`) and Fill bed refused for a cut object: no replaced replay exercised them.
- The rotations Auto-Orient gives the objects it may turn without a fixed result (placing, steps 14 and 15): which
face a cube resting on one already ends on is the job's choice; step 15 checks them against the reply. The rotation
of a mirrored instance or part (moving a part, from step 15; what the project keeps, instance 1): a mirror of a
turned shape can be written as another turn and a mirror, so only `mirrored` and the places are compared.
of a shape both turned and mirrored (moving a part, part 1 from step 15; what the project keeps, kept's instance 0):
a mirror of a turned shape can be written as another turn and a mirror, so only `mirrored` and the places are
compared, and kept's instance 0's turn by its box. A mirrored shape that is not turned reads `rotation_deg`
`[0, 0, 0]`, and is compared so (moving a part, step 16; what the project keeps, instance 1).
- How the objects look: a greyed instance that is not printable, the selection's highlight. No screenshot is taken.
- `app_state`'s `python` and `design_tab`, which `scene.json` read in passing: they are not object state.
- `app_state`'s `python` and `design_tab`: they are not object state.
`test_command_line` checks the unrestricted-scripts switch.
- `scene.json`'s end-to-end run as one scenario. Each of its steps is checked in the scenario of its command: the size
- An end-to-end run of all the commands on one scene. Each of its steps is checked in the scenario of its command: the size
of an object of several parts (moving a part, step 2), the instances of an object of parts made objects (the number
of instances, step 18), one plate arranged with options (arranging, step 13), Assemble and ordering by name across
plates (`test_object_structure`, splitting and ordering), Fill bed on another plate (arranging, step 17); its
@@ -319,10 +309,14 @@ opening a project makes plate 0 current.
- `object_list {screen: true}` and paging with `limit` and `offset`: no replaced replay used them, and they change how
`object_list` reports the objects, not what the objects are.
**Strength:** Strong — after every step it reads the plates and every instance back through `plate_list` and
`object_list` and compares them whole with values written out here: names, plates, instance counts, places to
0.001 mm, turns, scales, mirrors, printable flags and Auto Drop. It asserts each refusal by its code or its words,
counts undo steps by undoing them, holds what the arranger and Scale to Fit work out to stated properties and
tolerances, reads the copies a print leaves out in the G-code, and checks what the project keeps through the file.
## `test_object_structure`
`test_object_structure.py` · Python · takes the place of `menu_items_structure.json` and `objects_order.json`, and
with `test_objects` of `menu_items_objects.json`, `objects_state.json`, `objects_files.json` and `scene.json` · in
`sweep.json` as `{"path": "test_object_structure.py"}`
`test_object_structure.py` · Python, 506 checks · in `sweep.json` as `{"path": "test_object_structure.py"}`
**Tests:** What objects are made of and how the list orders them: renaming and deleting objects, and the layer commands
acting on the selected object; Split to Objects and to Parts, and Assemble; adding parts of every type, changing a
@@ -342,8 +336,10 @@ and 2.8 mm high, their centres 58 mm apart along x), `resources/handy_models/Orc
exports go to `W` as well. It does not use `tests/fixtures/objects_files.py` or `tests/fixtures/ops_undo.py`: undo
steps are counted by undoing them and reading the state back.
**Reads:** `plates()`, and `scene()`, `gcode_prints(path)` and `corner(p)` as `test_objects` reads them. Also:
- `names()`: the objects' names in index order; `types(o)`: object o's parts' `type`s in order.
**Reads:** `plates()`, and `scene()`, `selection()`, `gcode_prints(path)` and `corner(p)` as `test_objects` reads
them. Also:
- `names()`: the objects' names in index order; `types(o)`: object o's parts' `type`s in order; both from one
`scene()`.
- `notices()`: the texts of `app_state`'s `notifications`; `dialogs()`: the titles of its `dialogs`.
Every scenario starts with `project_new {discard_changes: true}` in the Prepare view and checks that `plates()` is
@@ -404,8 +400,8 @@ to 9, `[scaled]` after 10, `[plain]` after 11 to 20 and `[base]` after 21 and 22
| 5 | `part_add {object: 0, type: "part", shape: "cube", size: [10, 10, 20], position: corner(0) + (125, 100, 10)}` | part, part, negative, modifier | the reply's `part` 1: parts are listed by type; the new part named `Generic-Cube`, `filament` 1, `bbox.size` z 20 to 0.01; block's `bbox.size` z 20 |
| 6 | `part_add {object: 0, type: "support_blocker", shape: "sphere", position: corner(0) + (110, 110, 10)}` | part, part, negative, modifier, support_blocker | the blocker at +(110, 110, 10) |
| 7 | `part_add {object: 0, type: "precise_seam", shape: "cube", size: [2, 2, 2]}` | part, part, negative, modifier, support_blocker, precise_seam | the seam's `subtype` `center` |
| 8 | `part_add` with `{type: "modifier", shape: "cube", path: OrcaCube_v2.drc}`, `{type: "modifier", shape: "cylinder", size: [1, 2, 3]}`, `{type: "part", path: star.svg}` and `{type: "modifier", path: heightmap.png}`, each on object 0 | as after 7 after each | refused, saying in turn to give shape or path, that a cylinder's size is `[diameter, height]`, that SVG parts come from `object_add_svg`, and that the file could not be loaded |
| 9 | `object_set_instances {object: 0, count: 2}`, then `part_add {object: 0, type: "modifier", shape: "cube"}` | as after 7 | refused, saying object 0 has 2 instances |
| 8 | `part_add` with `{type: "modifier", shape: "cube", path: OrcaCube_v2.drc}`, `{type: "modifier", shape: "cylinder", size: [1, 2, 3]}`, `{type: "part", path: star.svg}` and `{type: "modifier", path: heightmap.png}`, each on object 0 | as after 7 after each | refused, saying in turn `Give shape or path`, `A cylinder's size is [Diameter, Height]`, `SVG parts come from object_add_svg` and `The file could not be loaded` |
| 9 | `object_set_instances {object: 0, count: 2}`, then `part_add {object: 0, type: "modifier", shape: "cube"}` | as after 7 | refused, saying `object 0 has 2 instances` |
| 10 | `project_new`; scaled, a 20 mm cube, `object_transform {object: 0, scale: 1.5}`, then `part_add {object: 0, type: "modifier", shape: "cube"}` | part, modifier | the reply's `part` 1; the instance's `scale` `[1, 1, 1]` and part 0's `[1.5, 1.5, 1.5]`, and the object's `bbox.size` `[30, 30, 30]`: adding a shape folds the instance's scale into the parts |
| 11 | `project_new`; plain, a 30 × 30 × 10 mm cube, then `part_add {object: 0, type: "modifier", shape: "cube", size: [10, 10, 10]}` | part, modifier | part 0 named plain, part 1 `Generic-Cube` |
| 12 | `object_select {parts: [[0, 1]]}`, then `part_change_type {type: "negative"}` | part, negative | no target changes the selected part; the reply's `parts` `[{object: 0, part: 1, type: "negative"}]` |
@@ -440,7 +436,7 @@ works on the current plate.
| 7 | `plate_add`, `plate_select {plate: 1}`, then `object_order {by: "size"}` | tall · mid · short | refused, `no_objects_to_order`: the current plate is empty |
| 8 | `object_order {by: "size", all: "every"}` | tall · mid · short | refused by the schema, saying `all must be of type boolean` |
| 9 | `object_order {by: "size", all: true}` | short · mid · tall | the reply's `descending` false and `order` short, mid, tall and no more: every plate's objects, by volume (4000, 8000, 12000 mm³) |
| 10 | `object_order {by: "name", all: true}` | mid · short · tall | the reply's `descending` false and `order` mid, short, tall: with the current plate empty, `all` orders plate 0's objects, by name as `scene.json` ordered them |
| 10 | `object_order {by: "name", all: true}` | mid · short · tall | the reply's `descending` false and `order` mid, short, tall: with the current plate empty, `all` orders plate 0's objects, by name |
| 11 | `plate_set_settings {plate: 0, values: {print_sequence: "by object"}}` | mid · short · tall | `plate_list` gives plate 0 `print_sequence` `by object` |
| 12 | `object_order {plate: 0, order: [2, 0, 1]}` | tall · mid · short | the reply's `order` tall, mid, short and no `descending` |
| 13 | `object_order {plate: 0, order: [0, 1, 2]}` | tall · mid · short | the reply's `order` tall, mid, short: the order they have changes nothing |
@@ -516,25 +512,23 @@ after 5 and 6, as replacing an object's only part names the object after the new
- That Assemble keeps the pieces where they stand (splitting, step 4), so the assembly's box is the two rings' box:
`ObjectList::merge()` gives each part its object's instance placement times its own.
- The open edges of `holed.stl` once imported (repairing, step 1): the loader's repair matches the edges it can and
leaves the hole, three edges. `objects_state.json` checked only more than 0.
- Fix Model's notice through the menu (repairing, step 5) is the text `objects_state.json` passes with,
`has been repaired`.
leaves the hole, three edges.
- Fix Model's notice through the menu (repairing, step 5) is matched by the words `has been repaired`.
- The modifier's move on Replace 3D file (files, step 9). The new mesh is moved by the difference between the two
meshes' centres in their files, (10, 10, 5) here, for an instance that is neither turned nor scaled. The cylinder's
centre is (0, 0, 5) only to its facets, hence 0.05.
- A reload that finds only missing files takes no undo step (files, step 6): `Ops::reload_parts()` reloads nothing,
so it takes no snapshot. The command's description says "One undo step" without that exception; this is MCP code
added on this branch, fixed when the test is written: in `src/slic3r/GUI/Mcp/McpToolsScene.cpp`,
`register_object_tools()`, `object_reload_from_disk`'s description says that a call that reloads nothing, its parts'
files all missing, takes no undo step, and so does the comment on `reload_parts()` in
`src/slic3r/GUI/Operations/ObjectOps.hpp`.
so it takes no snapshot. `object_reload_from_disk`'s description (`register_object_tools()` in
`src/slic3r/GUI/Mcp/McpToolsScene.cpp`) and the comment on `reload_parts()` in
`src/slic3r/GUI/Operations/ObjectOps.hpp` say so: one undo step, none when every part's file is missing.
- An order the objects already have takes no undo step (ordering, steps 13 and 14): `Ops::reorder_objects()` takes its
snapshot only when it moves an object, as `ObjectList::order_objects()`, the app's own code, takes one only when the
order changes. The command's description and the operations' comments say "one undo step" without that exception;
this is MCP code added on this branch, fixed when the test is written: in `src/slic3r/GUI/Mcp/McpToolsScene.cpp`,
`register_object_menu_commands()`, `object_order`'s description, and in `src/slic3r/GUI/Operations/ObjectOps.hpp`,
the comments on `order_objects()` and `reorder_objects()`, say that a call that leaves the order as it was takes no
undo step.
order changes. `object_order`'s description (`register_object_menu_commands()` in
`src/slic3r/GUI/Mcp/McpToolsScene.cpp`) and the comments on `order_objects()` and `reorder_objects()` in
`src/slic3r/GUI/Operations/ObjectOps.hpp` say so: one undo step, none when the order stays as it was.
- The words of `part_add`'s refusals (parts, steps 8 and 9) carry no code, so they are matched by their text. A
shape's size names the fields of Add Primitive's size dialog (`primitive_size_names()`), so a cylinder's is
`[Diameter, Height]`.
- The names of parts (parts, steps 11 and 21; what the project keeps, step 1): a part added as a shape is named
`Generic-` and its shape (`ObjectList::load_generic_subobject()`), and naming an object of one part names its part
too (`ObjectList::update_name_in_model()`), so the first part is named after the object while it has no other.
@@ -562,143 +556,11 @@ after 5 and 6, as replacing an object's only part names the object after the new
stop, which a 12-triangle cube is not. Reload from disk with `all`: no replaced replay used it; it reloads every
object but the cut ones through the same `Ops::reload_parts()`. A STEP file's mesh options on Replace 3D file:
`test_files` (the files entry) checks them.
- The order of objects of the same height, such as the two rings `menu_items_structure.json` ordered with its cubes:
- The order of objects of the same height, such as two rings beside cubes:
which of two equal objects comes first is the sort's. The ordering scenario's objects differ in height, size and
name, so the whole order is read at every step.
## Replays this area replaces
Each leaves the sweep, with its entry, in the commit that adds the tests above.
### `menu_items_objects`
`tests/menu_items_objects.json` · replay, 31 steps, 36 expects, 0 optional
**Tests:** The object commands made from menu items called by index and with no target on the selection: `object_rename`, `object_set_instances`, `object_separate_instances`, `object_delete` and the Delete Selected action, and `object_set_height_ranges` / `object_set_variable_layer_height` acting on the selected object.
**Decides by:** Fails when a call errors or an expect misses.
- Rename: the reply names object 1 "middle"; `object_list` has it on object 1 and not object 0.
- Instances: the reply gives object 0 with 3 instances; separating instance [0, 2] replies new object 3 and `object_list` shows 4 objects, object 0 with two instances.
- Delete: by index replies index 0 and `object_count` 3, leaving "middle" first; on the selection replies "middle" and count 2, and the list no longer starts with it; the `obj_delete` action replies count 1.
- Selection targets: height ranges reply object 1 "layered" with `max_z` 5, and `object_list` shows the range on object 1 and none on object 0; variable layer height replies object 1 "layered".
**Not checked:**
- Variable layer height is checked only by `/layer_height_profile` existing in the reply; `object_list` is not read, so a profile also landing on object 0 passes.
- The separated object's position or geometry is not read.
**Strength:** Strong — every command's target and result are read back by index and name.
### `menu_items_placement`
`tests/menu_items_placement.json` · replay, 51 steps, 67 expects, 0 optional
**Tests:** Placement commands by index: `object_add_primitive` on a plate and at a position in one undo step, `object_mirror`, `object_drop`, `object_center` (each on its own plate, then as a group on one plate), `object_scale_to_fit`, `object_auto_orient`, and the Center, Drop, Scale to Fit and Auto-Orient actions on the selection, on the X1C's 256 mm bed with three plates.
**Decides by:** Fails when a call errors or an expect misses.
- Add: replies `object`, `plate` 1 and name; the selection is [0]; the second cube's `offset` is 420/110 ± 0.01 on plate 1; the undo log shows exactly one "Add Primitive" snapshot (`ops_undo.taken()`, which reads the app log and asserts nothing); both names listed and the second on the bed.
- Mirror and drop: only object 0 is mirrored; a two-part object lifted 15 mm without drop has `min/2` ≥ 10, `object_drop` replies `moved` true and puts it at 0 ± 0.001, a second drop replies `moved` false; the `obj_drop` action replies `moved` true and drops it.
- Centre: by index replies plate 1 only and puts object 0 at 435.2/128 ± 0.1; objects 0 and 2 each go to their own plate's centre (reply groups exact, plate 2 at 128/−179.2 ± 0.1); a second call leaves them; all three on plate 1 replies [0, 1, 2], lists "third" on plate 1 and nothing outside; the Center action puts object 2 on plate 1's centre.
- Scale to fit: replies object 0 and 2 with scale > 5; object 0's listed scale > 5.
- Auto-orient: reply indices and object 2's `rotation_deg/0` 89.9–90.1, matched in `object_list`; the selection stays [1, 2]; the action with nothing selected replies rotations for objects 0–2 and no fourth.
**Not checked:**
- Scale to fit is checked as > 5, where the fitted factor follows from the bed; the action's scale is not read in `object_list`.
- The Auto-Orient action's rotations are not read, only which objects it processed.
- The group centring's resulting positions are not read, only plate membership and nothing outside.
**Strength:** Strong — positions are read back to 0.1 mm against the bed's geometry; Scale to Fit and the Auto-Orient action are loosely checked.
### `menu_items_structure`
`tests/menu_items_structure.json` · replay, 28 steps, 45 expects, 0 optional
**Tests:** The object structure commands by index: `object_split` into objects and into parts, `object_assemble`, `part_change_type`, `object_order` by height (ascending, repeated, descending), and the Split to Objects action on the selection, using a two-shell OBJ.
**Decides by:** Fails when a call errors or an expect misses.
- Split into objects: reply indices 0 and 1, `object_count` 2, each a single part.
- Split into parts: reply parts 0 and 1 of object 2, `object_count` 3; the list shows two parts of type "part".
- Assemble: reply object 1 "Assembly"; the list has 2 objects, both multi-part.
- Change type: the reply moves the new modifier to part 1; the list shows part, then modifier.
- Order: ascending puts the 10 mm cube at index 2 and the 30 mm at 3 (bbox ± 0.01); the same call again stays ascending; descending reverses it; the reply's `/descending` matches each time.
- The action splits object 4 into 4 and 5, `object_count` 6.
**Not checked:**
- Order by height reads only the two cubes' slots; the two-shell objects' relative order is not read.
- Split and assemble geometry (part sizes, positions) is not read.
**Strength:** Strong — each command's reply and the resulting list are matched by index, type and name.
### `objects_state`
`tests/objects_state.json` · replay, 42 steps, 45 expects, 0 optional
**Tests:** `object_set_printable` on one instance and on a whole object, `object_fix` on a cube missing a triangle (no dialog, no notice, one undo step), Fix Model through the object's menu ending in its notice, and `object_set_auto_drop` off letting a lifted object stay up.
**Decides by:** Fails when a call errors, a fixture raises, or an expect misses.
- Printable: the reply names only instance [0, 1]; `object_list` shows it false and its siblings and the other object true; undo restores it; naming object 0 sets all three of its instances and leaves object 1.
- Fix by index: before, `open_edges` > 0 and `manifold` false; the reply is not a job, `changed` true, open edges before > 0 and after 0; then `open_edges` 0 and `manifold` true; `repair_notices()` finds no notice and no dialog; exactly one "Repairing model object" snapshot.
- Fix by menu: the gesture replies `ran` "Modify>Fix Model"; `wait_repaired()` polls `object_list` and `app_state` for up to 30 s, then `open_edges` must be 0 and the first notice contain "has been repaired"; the undo log contains "Repairing model object".
- Auto drop: with it on, a 15 mm lift leaves `min/2` < 0.01; the reply and list show `auto_drop` false on object 0 only; then a lift leaves it at 15–35 mm.
- Fixtures `objects_files.py` and `ops_undo.py` assert nothing; `wait_repaired()` returns on timeout without raising, and the step's expects decide.
**Not checked:**
- The drop with Auto Drop on is `min/2` < 0.01 with no lower bound, so an object sunk below the bed passes.
- The menu path's undo check is `contains`, so extra snapshots pass.
**Strength:** Strong — each state change is read back per instance and object, with before-and-after mesh errors and a control for Auto Drop.
### `objects_order`
`tests/objects_order.json` · replay, 21 steps, 23 expects, 0 optional
**Tests:** `object_order {order}` putting three objects on a by-object plate in the order [2, 0, 1], as dragging them in the object list does; the same order again changes nothing; one undo restores the order.
**Decides by:** Fails when a call errors or an expect misses.
- `plate_set_settings` applies `print_sequence` "by object", and `plate_list` reads it back.
- The reply's `order` names and new indices are exact and there is no fourth; `object_list` lists third, first, second.
- `[0, 1, 2]` replies the same order, and one undo then restores first, second, third (which also shows the no-op added no undo step).
**Not checked:**
- The plate is never sliced, so the header's claim that this is the print order is not checked.
**Strength:** Strong — the order is read back by name from the reply, the list and after undo.
### `objects_files`
`tests/objects_files.json` · replay, 62 steps, 62 expects, 0 optional
**Tests:** `object_clone` by index and on a selected instance, the Clone dialog through the object's right-click menu, `object_reload_from_disk` of an overwritten and of a deleted file, and `part_replace` keeping a part's type, filament and position, a modifier staying a modifier, and painted supports kept with the `keep_painting` preference.
**Decides by:** Fails when a call errors, a fixture raises, or an expect misses.
- Clone: replies the new indices 1–3, `copied` object 0, `object_count` 4, `arranged`; nothing listed outside. The right-click gesture replies `ran` "Clone", the dialog is answered, no dialog remains and `object_count()` gives 5. Cloning selected instance [2, 1] replies that instance and new object 5 with one instance, object 2 keeping two.
- Reload: `mesh_volume` 8000, then exactly 27000 after the file is rewritten at 30 mm; the reply names part 0 and the path, with `missing` and `unmatched` empty; exactly one "Reload from disk" snapshot; after removal the reply lists the part under `missing`, `reloaded` is empty, no dialog opens and the volume stays 27000.
- Replace: `replace_keeps()` (object_list read before and after) gives a new part id, type "part", filament 2 and `moved` < 0.01; the modifier replace gives volume 8000, type "modifier" and the same filament; exactly two "Replace with 3D file" snapshots.
- keep_painting: enforcers > 0 before; the checkbox is clicked in the Preferences dialog and `preferences_get` reads true; after `part_replace` with the same box, enforcers > 0.
- Fixture `objects_files.py` asserts nothing: it writes STL files, calls tools and returns dicts. A tool error raises `ToolError`; `remove()` returns `removed` false rather than raising. `ops_undo.py` reads the app log and asserts nothing.
**Not checked:**
- keep_painting has no control case: a replace with the preference off is never tried, so a `part_replace` that always keeps painting, or ignores the preference, passes.
- The modifier's move by the file-origin difference, which the comment describes, is not matched (`moved` is returned but unchecked for part 1).
- Arranged clones are checked only as not outside the plates.
**Strength:** Partial — clone, reload and replace are checked exactly, but the keep_painting section cannot tell the preference's effect from the default.
### `scene`
`tests/scene.json` · replay, 208 steps, 203 expects, 23 optional
**Tests:** `object_transform` on instances, parts and plates; what `object_list`, `object_select` and `app_state` report; shapes at a size; `object_arrange` and Fill bed; `part_add`; the object list's context-menu commands through `action_run` (Change Type, Rename, instances, Set as Individual Objects, Assemble, Order By); then all of them on one scene, sliced.
**Decides by:** Fails when a non-optional call errors or an expect misses.
- Instance and part transforms: after a scale the bbox `min/2` is 0 ± 0.001; `size` keeps proportions and sets exact sizes (± 0.01); a plate move replies `/plate` 1 and `object_list {plate: 1}` lists it; part translate, relative move, scale and size replies match to 0.01 (or 0.001), and one undo takes back one part move.
- `object_list` fields: object and part `filament` 1, `auto_drop` true, `mirrored` flags, instance bbox, part position, part bbox and volume ranges.
- Selection: `object_select` replies `/canvas`, `/objects`, `/instances`, `/parts` exactly, also for one instance of two; `app_state /selection/parts` and `/selection/instances` match.
- Mirror: a mirrored part is mirrored and its instance not; the instance mirrored on Y then X reads unmirrored.
- Shapes and arrange: `object_add_primitive` sizes ± 0.01, a wrong-count size adds nothing (`total` 2), a size adds the shape with an object selected; Fill bed replies `/added` > 0 on plate 1 with nothing off the plate, its instance listed then gone after one undo; arranging plate 0 replies `spacing` 10, `rotate` false, 2 plates, and plate 1 keeps "Cylinder" while plate 0 has two objects; Arrange and the `obj_arrange` action reply the saved spacing 10.
- `part_add`: replies give part index, `part_count`, type, position, bbox (± 0.01), name "OrcaCube_v2.drc", filament 1, subtype "center"; undo removes and redo restores the negative part; parts are ordered by type (2 negative, 3 modifier, 6 parts); after four optional refusals and a two-instance refusal there is still no part 6; a shape folds the instance's 1.5 scale into the parts.
- Structure commands: each Change Type read back, one undo each; the refused changes and the SVG part's refused change leave the types; renames "base" and "infill zone" kept over a refused "a/b"; 6 instances undone, 3 kept over refused 0 and "three"; instances to objects reply indices and `total` 4; Assemble replies object 2 "Assembly", `total` 3.
- Order By: ascending then descending, reply `/descending` and bbox heights in list order; refusals leave the order; `object_order {all: true}` ascending.
- End to end: block 50 wide and 18.75 tall on the bed, moved to plate 1, 6 instances arranged there with plate 0 empty, 6 objects each with "boss" and a negative part, mirror on object 5 only, Assemble as object 4 with the mirrored one at index 3, order by name with "Assembly" first, Fill bed adds > 0 on plate 1, plate 1 slices "ok".
**Not checked:**
- Refusals whose follow-up reads nothing they would change: the absolute rotation of a part (rotation never read), the part move on single-part object 1 (position never read), Arrange on a locked plate (positions never read), `fill_object 0` with `plates 0` (only plate 1's object is read), `plates 7` (only that there is no plate 2), Set as Individual Objects on a single instance.
- The Speed Dial `obj_mirror_x` with nothing selected, which the header and README call "an error step", is optional, so it checks nothing in either direction.
- Arrange options: `spacing` and `rotate` are checked only as echoes in the reply; no position or gap between objects is read.
- Loose: Fill bed `/added` > 0; `app_state /python/scripts_unrestricted` and `/design_tab` only `ne null`; the SVG part's bbox and volume ranges (documented: its orientation varies).
- Mirroring is checked by the `mirrored` flag only, not by geometry.
- The end-to-end Fill bed result is not read in `object_list`; the slice is checked only by outcome; the screenshot is never compared.
**Strength:** Partial — transforms, `part_add` and the structure commands are read back exactly, but about half of the refusals and the arrange options have no check that could fail.
**Strength:** Strong — after every step it reads the objects back through `object_list` and compares their names, and
their parts' types where a row writes them, whole with values written out here; it asserts each refusal by its code or
its words, counts undo steps by undoing them, checks the print order in the G-code and what the project keeps through
the file, and shows keep_painting's effect against the preference turned off.
+37 -112
View File
@@ -4,8 +4,7 @@ The design of this area's sweep tests. The rules every entry follows, the grades
in [TESTS.md](../TESTS.md).
## `test_presets`
`test_presets.py` · Python · takes the place of `presets.json`, `presets_and_plate_map.json` and `ops_select_preset.json`,
and of the removed `ops_import_presets.json`
`test_presets.py` · Python, 511 checks · in `sweep.json` as `{"path": "test_presets.py"}`
**Tests:** The presets of the three types, through the tools a person's preset work maps to: selecting a preset by
the name its selector shows, hidden ones included (`preset_select`); listing presets with filters (`preset_list`);
@@ -236,8 +235,8 @@ It starts by selecting "MCP Test PLA" in slot 1.
| 1 | `preset_save {type: process, name: "MCP Project Process", inside_project: true}` | `X1C \| MCP Project Process \| MCP Test PLA` | reply `project` true, `user` false, `inherits` Std; `listed(process, query: "MCP Project Process")` is one item, `selected`, `project` true, `user` false |
| 2 | `preset_save {type: process, name: "MCP Detached", detach: true}` | as after 1 | refused, "Detach is offered only in Developer mode"; `listed(process, query: "MCP Detached")` is empty |
| 3 | the `toggle_developer_mode` action, the same save, the action again | `X1C \| MCP Detached \| MCP Test PLA` | reply `project` true and no `inherits` |
| 4 | `object_add_primitive {shape: "cube"}`, `project_save` to a new file, `project_new {discard_changes: true}` | `X1C \| Std \| MCP Test PLA` | `listed(process, query: "MCP")` is empty: presets inside a project leave with it |
| 5 | `project_open` of the file | `X1C \| MCP Detached \| MCP Test PLA` | `listed(process, query: "MCP")` is "MCP Detached" and "MCP Project Process", both `project` true and `user` false; "MCP Test PLA" is `selected` and not `modified` |
| 4 | `object_add_primitive {shape: "cube", size: [20, 20, 20]}`, `project_save` to a new file, `inside.3mf`, `project_new {discard_changes: true}` | `X1C \| Std \| MCP Test PLA` | `listed(process, query: "MCP")` is empty: presets inside a project leave with it |
| 5 | `project_open` of the file | `X1C \| MCP Detached(inside.3mf) \| MCP Test PLA` | `listed(process, query: "MCP")` is "MCP Detached(inside.3mf)", `user` true and no `project` field, and "MCP Project Process", `project` true and `user` false; "MCP Test PLA" is `selected` and not `modified` |
**Scenario: deleting presets**
@@ -335,8 +334,16 @@ The test writes into a folder of its own. `costs()` reads `filament_cost` of "MC
Transfer offered, since a process can always take a transfer (`Tab::can_transfer_changes_to()`).
- After a project with project presets is replaced by a new one (inside the project, step 4), the process is expected
to fall back to Std: `PresetBundle::reset_project_embedded_presets()` leaves no process selected and the
compatibility update picks the printer's default. After reopening it (step 5), the process the project was saved
with, "MCP Detached", is selected. The replay read neither.
compatibility update picks the printer's default. The replay read neither.
- A detached preset inside the project does not come back as one (inside the project, step 5). Loading a project skips
each preset kept inside it that has no parent (`PresetCollection::load_project_embedded_presets()` in
`src/libslic3r/Preset.cpp`, which logs "can not find parent"), so "MCP Detached" is not loaded. The process the
project was saved with is then made from the project's own settings as an external preset named after the preset
and the file, "MCP Detached(inside.3mf)" (`PresetCollection::load_external_preset()`), which is selected and listed
as a user preset. That is the app's own code, as on `main` (commit 8c64808ae5), left as it is: a detached preset
that does not survive its project is a bug for a fix of its own. Step 5 expects what the app does today.
- `object_add_primitive` with a shape alone asks for the size in the Primitive size dialog, as the shape's Speed Dial
action does, so step 4 gives the cube a size.
- The process selected after deleting a selected preset with no parent (deleting, step 11) is the tab's next visible
preset, which depends on the collection's order; the entry checks only that it is a system process.
- The 0.6 nozzle's process and filament (nozzle diameter, step 1). The X1C 0.6 has never been used, so nothing is
@@ -362,7 +369,7 @@ The test writes into a folder of its own. `costs()` reads `filament_cost` of "MC
- That `preset_export` with a path is held by a dialog titled Export Preset Bundle: checked in `test_person_forms`;
here the dialog is driven to a written file and the file read.
- `preferences_set` and the Preferences dialog tab by tab: checked in `test_preferences`; this test changes one control
in the dialog only, as `presets.json` did.
in the dialog only.
- `preset_sync`: checked in `test_additions_refusals`.
- The undo snapshots of preset selections and imports, which `ops_import_presets` recorded through `ops_undo.py`: no
tool lists the undo history, and a preset's change is not in it (`settings_set`'s description).
@@ -377,13 +384,14 @@ The test writes into a folder of its own. `costs()` reads `filament_cost` of "MC
- How the dialogs look: no screenshot is taken.
**Fixtures:** the test uses `tests/fixtures/mcp_import_pla.json` and `heightmap.png`, and writes its other files.
`tests/fixtures/presets_and_plate_map.py` has no other user and goes with `presets_and_plate_map.json`. Of
`tests/fixtures/ops_presets.py`, `test_operation_routes.py` uses `preset_api` alone; `arrange_presets` goes with
`ops_select_preset.json`, while `arrange_filaments`, `probe` and `drop_filament_edits` stay for the
`ops_assign_filament_preset_*` replays until they leave.
**Strength:** Strong — after every step it reads the selection back, each preset with its unsaved edits and their
values, and compares it whole with values written out here; it asserts each refusal by its code or its words, each
prompt by its title and buttons, and checks an exported preset through its file and the selected presets and an
unsaved edit through the G-code.
## `test_calibration`
`test_calibration.py` · Python · takes the place of `calibration.json`
`test_calibration.py` · Python, 307 checks · in `sweep.json` as `{"path": "test_calibration.py"}`
**Tests:** `calibration_generate_test` for every test and method of the Calibration menu: the project it makes, the
parameters it uses, the presets and objects it changes, the warnings for values it rounds or the printer may not
@@ -437,17 +445,17 @@ true}` and leaves the selection `X1C | Std | PLA[nozzle_temperature 230,230, noz
|---|---|---|
| 1 | `{test: "max_volumetric", end: 15}` | `project` "Max volumetric speed test"; `params` `{start: 5, end: 15, step: 0.5}`; `names` `["SpeedTestStructure.drc"]`, 22 mm high to 0.01; `discarded.filament` is `{name: PLA, keys: [nozzle_temperature, nozzle_temperature_initial_layer]}`, and `nozzle_temperature` reads "220,220" again; sets filament `filament_max_volumetric_speed` "200,200" and `slow_down_layer_time` "0", which are the filament's whole `changes`, and process `spiral_mode` "1"; `result_keys` `{type: filament, keys: [filament_max_volumetric_speed]}`; a slice |
| 2 | `{test: "pressure_advance", end: 0.06}` | `project` "Pressure Advance Test"; `params` `{method: tower, start: 0, end: 0.06, step: 0.002}`; `names` `["tower_with_seam.drc"]`; sets filament `slow_down_layer_time` "1", the filament's whole changes; `result_keys` `{type: filament, keys: [enable_pressure_advance, pressure_advance]}`; a slice, whose `M900 K<k>` values in the layers, repeats in a row dropped, are exactly 0, 0.002, 0.004 … 0.06, the 31 bands, each to 0.0001 |
| 3 | `{test: "pressure_advance", method: "line", print_numbers: false}` | `params` `{method: line, start: 0, end: 0.1, step: 0.002, print_numbers: false}`; `names` `["pressure_advance_test.drc"]`; sets process `wipe_inward` "0" and `retract_after_outer_wall` "0", and no filament key: the filament's changes are empty |
| 4 | `{test: "pressure_advance", method: "pattern", accelerations: [1000, 2000], speeds: [50, 100]}` | `params` `{method: pattern, start: 0, end: 0.08, step: 0.005, accelerations: [1000, 2000], speeds: [50, 100]}`; `names` `["pa_pattern_50_1000", "pa_pattern_100_1000", "pa_pattern_50_2000", "pa_pattern_100_2000"]`; sets filament `filament_retract_when_changing_layer` and `filament_wipe` 0 in every entry (the profile has nil), the filament's whole changes, and printer `wipe` and `retract_when_changing_layer` 0 in every entry; `result_keys` `{type: filament, keys: [enable_pressure_advance, pressure_advance, adaptive_pressure_advance, adaptive_pressure_advance_model]}`; a slice |
| 5 | `{test: "pressure_advance", method: "pattern"}` | `params` `{method: pattern, start: 0, end: 0.08, step: 0.005, accelerations: [a], speeds: [s]}`, where `a` and `s` are the first entries of the process's `outer_wall_acceleration` and `outer_wall_speed` read after the call, both above 0: the pattern's defaults are the process's; `names` `["pa_pattern_<s>_<a>"]`, the two as whole numbers; sets as row 4 |
| 3 | `{test: "pressure_advance", method: "line", print_numbers: false}` | `project` as row 2; `params` `{method: line, start: 0, end: 0.1, step: 0.002, print_numbers: false}`; `names` `["pressure_advance_test.drc"]`; sets process `wipe_inward` "0" and `retract_after_outer_wall` "0", and no filament key: the filament's changes are empty |
| 4 | `{test: "pressure_advance", method: "pattern", accelerations: [1000, 2000], speeds: [50, 100]}` | `project` as row 2; `params` `{method: pattern, start: 0, end: 0.08, step: 0.005, accelerations: [1000, 2000], speeds: [50, 100]}`; `names` `["pa_pattern_50_1000", "pa_pattern_100_1000", "pa_pattern_50_2000", "pa_pattern_100_2000"]`; sets filament `filament_retract_when_changing_layer` and `filament_wipe` 0 in every entry (the profile has nil), the filament's whole changes, and printer `wipe` and `retract_when_changing_layer` 0 in every entry; `result_keys` `{type: filament, keys: [enable_pressure_advance, pressure_advance, adaptive_pressure_advance, adaptive_pressure_advance_model]}`; a slice |
| 5 | `{test: "pressure_advance", method: "pattern"}` | `project` as row 2; `params` `{method: pattern, start: 0, end: 0.08, step: 0.005, accelerations: [a], speeds: [s]}`, where `a` and `s` are the first entries of the process's `outer_wall_acceleration` and `outer_wall_speed` read after the call, both above 0: the pattern's defaults are the process's; `names` `["pa_pattern_<s>_<a>"]`, the two as whole numbers; sets as row 4 |
| 6 | `{test: "flow_ratio"}` | `project` "Orca YOLO Flow Calibration"; `params` `{method: yolo, top_surface_pattern: archimedeanchords}`; `names` "flowrate_0", "flowrate_0.01" to "flowrate_0.05", "flowrate_m0.01" to "flowrate_m0.05", the 11 of `Orca-LinearFlow.3mf` in its order; sets process `layer_height` "0.2", and no filament key (rows 6 to 9): the filament's changes are empty; `result_keys` `{type: filament, keys: [filament_flow_ratio]}`; each object's own `print_flow_ratio` is `(0.98 + m) / 0.98` to 0.0001, `m` being the number its name ends in ("m" for minus) and 0.98 the filament's flow ratio, and its own `top_surface_pattern` is "archimedeanchords"; a slice |
| 7 | `{test: "flow_ratio", method: "yolo_perfectionist"}` | `project` "Orca YOLO Flow Calibration - Perfectionist version"; `params` `{method: yolo_perfectionist, top_surface_pattern: archimedeanchords}`; `names` the 16 of `Orca-LinearFlow_fine.3mf` in its order, "flowrate_0", "flowrate_0.005" to "flowrate_0.035" and "flowrate_m0.005" to "flowrate_m0.04"; flow ratios as in row 6 |
| 8 | `{test: "flow_ratio", method: "pass1"}` | `project` "Flowrate Test - Pass1"; `params` `{method: pass1, top_surface_pattern: archimedeanchords}`; `names` "flowrate_0", "flowrate_10", "flowrate_15", "flowrate_20", "flowrate_5", "flowrate_m10", "flowrate_m15", "flowrate_m20", "flowrate_m5", as `flowrate-test-pass1.3mf` holds them; each object's own `print_flow_ratio` is `1 + m / 100` to 0.0001 |
| 9 | `{test: "flow_ratio", method: "pass2", top_surface_pattern: "monotonic"}` | `project` "Flowrate Test - Pass2"; `params` `{method: pass2, top_surface_pattern: monotonic}`; `names` "flowrate_0", "flowrate_m1" to "flowrate_m9", as `flowrate-test-pass2.3mf` holds them; flow ratios as in row 8; each object's own `top_surface_pattern` is "monotonic" |
| 10 | `{test: "retraction", end: 1}` | `project` "Retraction"; `params` `{start: 0, end: 1, step: 0.1}`; `names` `["retraction_tower.drc"]`, with its own `layer_height` "0.2"; sets printer `use_firmware_retraction` "0", and no filament key: the filament's changes are empty; `result_keys` `{type: filament, keys: [filament_retraction_length]}`; a slice. Its layers are cut into bands at each `; Calib_Retraction_tower: Z_HEIGHT: <z>, length:<L>` line: the bands' lengths `L`, repeats in a row dropped, are exactly 0, 0.1 … 1, and in each band every deretraction (a `G1` with `E` and `F` alone and `E` above 0) restores exactly that band's `L`, to 0.001, the band of 0 having none: the retraction the tower sets is the one the printer performs |
| 10 | `{test: "retraction", end: 1}` | `project` "Retraction"; `params` `{start: 0, end: 1, step: 0.1}`; `names` `["retraction_tower.drc"]`, with its own `layer_height` "0.2"; sets printer `use_firmware_retraction` "0", and no filament key: the filament's changes are empty; `result_keys` `{type: filament, keys: [filament_retraction_length]}`; a slice. Its layers are cut into bands at each `; Calib_Retraction_tower: Z_HEIGHT: <z>, length:<L>` line: the bands' lengths `L`, repeats in a row dropped, are exactly 0, 0.1 … 1, and in each band every deretraction (a `G1` with `E` and `F` alone and `E` above 0) restores exactly that band's `L`, to 0.001, and each `L` above 0 has at least one; the bands of 0 restore 0.8 alone, the printer's `retraction_length`: the first layer's retraction, made at the layer change before the tower's first line. The retraction the tower sets is the one the printer performs |
| 11 | `{test: "vfa"}` | `project` "VFA test"; `params` `{start: 40, end: 200, step: 10, auto_scale: true, auto_adjust: true}`; `names` `["vfa.drc"]`, with its own `layer_height` "0.2"; no `adjusted`; sets filament `slow_down_layer_time` "0", the filament's whole changes, and process `spiral_mode` "1", `wall_loops` "1", `top_shell_layers` "0", `bottom_shell_layers` "1", `sparse_infill_density` "0%" and `enable_overhang_speed` 0 in every entry; `result_keys` `{type: printer, keys: [resonance_avoidance, min_resonance_avoidance_speed, max_resonance_avoidance_speed]}`; a slice |
| 12 | `{test: "vfa", end: 400, step: 20}` | `params` `{start: 40, end: 400, step: 20, auto_scale: true, auto_adjust: true}`; `adjusted.layer_height` is below 0.2, and the object's own `layer_height` reads that value: the tower prints thinner layers to stay within the filament's volumetric speed |
| 13 | `{test: "vfa", end: 400, auto_adjust: false}` | `params` `{start: 40, end: 400, step: 10, auto_scale: true, auto_adjust: false}`; no `adjusted`; one warning, starting "the end speed (400 mm/s) exceeds the filament's maximum volumetric speed (21 mm³/s)" and ending "(auto_adjust and auto_scale lower the layer height to reach it)"; the object's own `layer_height` is "0.2", half the nozzle, as without the warning |
| 12 | `{test: "vfa", end: 400, step: 20}` | `project`, `names`, sets and `result_keys` as row 11; `params` `{start: 40, end: 400, step: 20, auto_scale: true, auto_adjust: true}`; `adjusted.layer_height` is below 0.2, and the object's own `layer_height` reads that value: the tower prints thinner layers to stay within the filament's volumetric speed |
| 13 | `{test: "vfa", end: 400, auto_adjust: false}` | `project`, `names`, sets and `result_keys` as row 11; `params` `{start: 40, end: 400, step: 10, auto_scale: true, auto_adjust: false}`; no `adjusted`; one warning, starting "the end speed (400 mm/s) exceeds the filament's maximum volumetric speed (21 mm³/s)" and ending "(auto_adjust and auto_scale lower the layer height to reach it)"; the object's own `layer_height` is "0.2", half the nozzle, as without the warning |
| 14 | `{test: "input_shaping_freq", start: 20, end: 80}` | `project` "Input shaping Frequency test"; `params` `{start: 20, end: 80, start_y: 20, end_y: 80, damping: 0.15, shaper_type: "Default", test_model: "ringing_tower"}`; `names` `["ringing_tower.drc"]`; sets filament `slow_down_layer_time` "0", `slow_down_min_speed` "0", `slow_down_for_layer_cooling` "0", and `enable_pressure_advance` 1 and `pressure_advance` 0 in every entry (the test turns pressure advance on at 0 where the filament has it off, as the PLA does), the filament's whole changes; printer `machine_max_jerk_x` and `machine_max_jerk_y` "10" (the X1C's 9 raised to 10) and `input_shaping_emit` "0"; process `spiral_mode` "1", `wall_loops` "1", `top_shell_layers` "0", `bottom_shell_layers` "1", `sparse_infill_density` "0%", `enable_overhang_speed` 0 in every entry, `accel_to_decel_enable` "1", `accel_to_decel_factor` "100%", and `outer_wall_speed` in every entry the smaller of the printer's `machine_max_speed_x` and `machine_max_speed_y` first entries, `default_acceleration` and `outer_wall_acceleration` in every entry its `machine_max_acceleration_extruding` first entry, those three read from the printer; `result_keys` `{type: printer, keys: [input_shaping_emit, input_shaping_type, input_shaping_freq_x, input_shaping_freq_y, input_shaping_damp_x, input_shaping_damp_y]}` |
| 15 | `{test: "input_shaping_damp", freq_x: 48, freq_y: 42, test_model: "fast_tower"}` | `project` "Input shaping Damping test"; `params` `{freq_x: 48, freq_y: 42, start: 0, end: 0.4, shaper_type: "Default", test_model: "fast_tower"}`; `names` `["fast_tower_test.drc"]`; sets as row 14 |
| 16 | `{test: "cornering", test_model: "scv_v2", end: 25}` | `project` "Cornering test"; `params` `{start: 1, end: 25, test_model: "scv_v2"}`; `names` `["SCV-V2.drc"]`; `warnings` exactly "end 25 is above 20: high values may cause layer shifts"; sets printer `machine_max_jerk_x` and `machine_max_jerk_y` "25", `input_shaping_emit` "1" and `input_shaping_type` "Disable", and filament `slow_down_layer_time` "0", `slow_down_min_speed` "0", `slow_down_for_layer_cooling` "0", `filament_max_volumetric_speed` "200", and `enable_pressure_advance` 1 and `pressure_advance` 0 in every entry, the filament's whole changes; `result_keys` `{type: printer, keys: [machine_max_jerk_x, machine_max_jerk_y]}`; a slice |
@@ -477,13 +485,17 @@ true}` and leaves the selection `X1C | Std | PLA[nozzle_temperature 230,230, noz
set from the layer's height (`start + floor(z - 0.4) * step`) on a tower cut at `1.4 + (end - start) / step` mm, so
its last band is expected to be 1. A deretraction is expected to restore exactly the retracted length on the X1C,
whose `retract_restart_extra` is 0, and nothing else in the layers to have that shape.
- The first band of the retraction tower (other tests, row 10). The first layer change retracts by the printer's
`retraction_length`, 0.8, before `GCode.cpp` writes the tower's first `; Calib_Retraction_tower:` line and sets its
length, so the deretraction that ends that travel, `G1 E.8`, falls in the first band of length 0. That is the app's
own G-code code, as on `main` (the line's code is from commits `40928a5d22`, `8a6573db19` and `0da24cd38b`, all on
`main`), left as it is; the row expects the 0.8 there and no other deretraction in the bands of 0.
- The objects' order in `names` for the flow ratio tests (other tests, rows 6 to 9) is expected to be the order the
shipped `resources/calib/filament_flow` model files hold them in; the replay matched only the first and the second.
shipped `resources/calib/filament_flow` model files hold them in.
- The VFA warning's maximum volumetric speed (other tests, row 13) is the filament's first entry, 21 mm³/s, for the
Direct Drive Standard extruder in use, and the VFA model's object is named after its file, "vfa.drc", as the others
are.
- Discarding on the test (keep and discard, step 3) leaves slot 2 on "MCP Calib PLA" without its edit; the replay read
only the reply.
- Discarding on the test (keep and discard, step 3) leaves slot 2 on "MCP Calib PLA" without its edit.
**Not checked:**
- The speeds the max volumetric and VFA towers step per layer: the G-code gives a move's feed rate, which the reader
@@ -502,94 +514,7 @@ true}` and leaves the selection `X1C | Std | PLA[nozzle_temperature 230,230, noz
**Fixtures:** none.
## Replays this area replaces
Each leaves the sweep, with its entry, in the commit that adds the tests above.
### `presets`
`tests/presets.json` · replay, 207 steps, 209 expects, 19 optional
**Tests:** `preset_save` (user, inside the project, detached, the overwrite rule), dropping and reverting edits with `settings_set` (`reset_all`, `null`, `reset_to`), reading settings' meta, searches and comparisons with `settings_get`/`settings_list`, per-variant values, `changed` after the spiral vase dialog, the unsaved-changes prompt through `preset_select` and `project_new`, `preset_delete`, export through the Export Preset Bundle dialog and `preset_import`, Preferences against `preferences_get`, and selecting hidden presets.
**Decides by:** Fails when a non-optional call errors or an expect misses.
- Hidden presets: a not-installed filament is listed and selected by name; switching to the hidden A1 mini lands slot 1 on a filament matching `@BBL A1M$`.
- Meta and search: `seam_slope_type` description contains "scarf joint", `where` "Quality > Seam", label "Contour"; `unknown_keys` and the `type_of` map exact; the printer search for "ooze during long travel" ranks `retraction_length` first at "Extruder > Retraction".
- Saving: `preset_save` replies `saved`, `user`, `project`, `inherits`, `selected`, `filament_slots`; the saved preset is listed selected and unmodified, with `compatible_printers` naming the X1C 0.4; compare `:saved` total 0 and `:parent` total 2 with "22"; the overwrite rule is followed by a list showing "MCP Test PLA 2" still selected, and the overwrite save reads cost "23".
- Reset and revert: `reverted` lists exact (`sparse_infill_density`, then `["wall_loops"]`, then empty); a bad value leaves "6"; `null` reverts to "2"; `reset_to: parent` gives "15.99" and back to "23".
- Reading and comparing: `:saved` gives exactly the two edits with `left` "... (edited)" and `other` "15%"; named presets read "2" and "0.16" without being selected; compare against "0.16mm Optimal" exact; `fuzzy_skin` values and labels.
- Per-variant values: variants and active entry exact; a scalar writes "250,350", an index write "250,300", the filament "215,220", compared entry by entry; reset gives "220,220".
- Spiral vase: `changed` lists `spiral_mode` "1", `wall_loops` "1", `top_shell_layers` "0", density "0%".
- Project preset: inside-project save is `project` true, `user` false; detach outside Developer mode leaves none, inside it saves without `inherits`; after a 3MF save, new project and reopen it is listed again and the filament is still selected and unmodified.
- Prompts: the dialog title is "Transfer or discard changes"; the job and the `preset_changes` replies give `selected`, `modified/.../keys` and `discarded/.../keys` exactly, including the Simple-mode-hidden key discarded and the filament keeping its change; the filament-type transfer refusal leaves "MCP Test PLA" selected; `project_new` keeps or discards as asked.
- Delete: a system preset survives a refused delete; deletes reply `deleted`, `selected`, `filaments`, `discarded`; refusals for unsaved changes, a base with a child and an unselected printer each leave the preset listed.
- Export and import: the Info dialog reads "Export successful", the export job `level` is "success", imports reply exact messages ("Kept the existing presets: ...", "Imported presets: ..."), the JSON import inherits "Bambu PLA Basic @BBL X1C" with cost "24", and no "MCP " preset is left.
- Preferences: refusals leave no dialog open; the checkbox reply `checked` and `preferences_get` value are false, then true.
**Not checked:**
- The printer transfer refusal: the follow-up (`printer_notes` still unsaved) also holds if the transfer to the same printer were accepted.
- `settings_set` refusing the preference `auto_arrange`: the preference is not read before the dialog sets it to the same false.
- Loose: the search without a type checks only a key ending in `retraction_length`, a type matching `filament|printer` and that a value exists; `settings_list` by `where` checks only that a value and description exist; the A1 mini's filament by pattern.
- No refusal's reason is asserted; README defers them to `test_additions_refusals.py`, which I did not check for these cases.
- `app_wait {for: job}` for the export dialog and the two Preferences jobs have no expect; a wait that times out still passes (the following reads catch most consequences).
**Strength:** Strong — nearly every step's reply or read-back is matched to an exact preset name, key list or value; the gaps are two refusals the follow-ups cannot tell from success and a few pattern-matched searches.
### `presets_and_plate_map`
`tests/presets_and_plate_map.json` · replay, 21 steps, 29 expects, 0 optional
**Tests:** `preset_list` filters (vendor, filament type, source, `include_uninstalled`, `printer`) and fields, `nozzle_diameter` selecting the matching nozzle preset, and a single-extruder plate's filament grouping read and refused.
**Decides by:** Fails when a call errors, a fixture raises, or an expect misses.
- `listed()` reads every page: Bambu Lab PLA filaments are found, none fails the vendor/type filter or lacks `vendor`/`filament_type`, none is Template; with lower-case filter values the first item reads "Bambu Lab"/"PLA".
- Printers with `include_uninstalled` include the X1C 0.2 nozzle, every system printer has `vendor`, `printer_model` and `nozzle`, none is Template; the X1C 0.4 entry reads vendor "BBL", model, nozzle "0.4", selected.
- `fitting()`: some filaments fit the 0.2 nozzle preset that the selected printer does not list, and none of them is marked incompatible.
- `nozzle_diameter` 0.6 applies "0.6", selects the 0.6 nozzle preset with `printer_variant` "0.6"; 0.4 selects the 0.4 preset again.
- A saved filament is listed by `source: user`, every listed item is user and not project, and `source: system` finds none by its name.
- The plate's `filament_map_mode` is "Auto For Flush" with no offered modes and `filament_map` effective [1]; `refused()` shows `plate_set_settings` Manual raises with a message containing "this one has one".
- Fixture `presets_and_plate_map.py` asserts nothing; it returns counts and name lists. `refused()` turns any exception into `refused: true` (broad except); the message match keeps an unrelated error from passing.
**Not checked:**
- `fitting()` returns `only_selected` (0.4-only filaments that should drop out) but it is not matched; the check only shows the two lists differ somewhere.
- Lower-case filters are checked on the first item only; the Bambu PLA count is only > 0.
**Strength:** Strong — the filter checks hold for every listed item, and the nozzle switch and plate map are exact.
### `ops_select_preset`
`tests/ops_select_preset.json` · replay, 250 steps, 89 expects, 78 optional
**Tests:** Selecting a process (0.20mm Standard to 0.16mm Optimal) or printer preset (X1 Carbon to X1E) through `preset_select` and the plugin API's `process`/`printer` `begin_update(name)`: an ordinary selection, unsaved changes (each `preset_changes` value and none, the prompt answered each way), the preset already edited, a hidden printer, and the refusals (no such name, an alias, an incompatible preset, the slot form on the process editor).
**Decides by:** Fails when a non-optional call errors, a fixture raises, or an expect misses. Every expect sits on setup.
- Case setup (`arrange_presets`, 29 steps): no dialog open; printer and process tab names by regex, with ` (modified)` on the dirtied one. A prompt the previous case left open fails here.
- Setup: one filament slot.
- Implicit: non-optional `preset_select` calls must succeed without a prompt: the process selection with no changes, with `transfer` and `discard`; the hidden X1E selected twice; the printer with `discard`.
**Not checked:**
- No `probe()` after a call is asserted, so a `preset_select` that returns ok but leaves the old preset in the tab passes; the next `arrange_presets` resets the state either way.
- The plugin API route cannot fail (`preset_api` catches exceptions), including the hidden X1 it should select. `test_operation_routes.py` checks a hidden printer through the plugin API.
- Whether the prompt opens, and that the printer prompt offers no Transfer: `app_wait {for: dialog}` cannot fail, the answers are optional, and the printer `preset_changes: "transfer"` call is optional.
- The refusals and their codes and texts.
- The clean-case regex `^0.20mm Standard @BBL X1C` has no `$`, so it also matches a name with ` (modified)`.
**Strength:** Smoke — the tool route must succeed without a prompt, but which preset each call leaves selected is never asserted.
### `calibration`
`tests/calibration.json` · replay, 58 steps, 39 expects, 8 optional
**Tests:** `calibration_generate_test` for every test and method (temperature, max volumetric, pressure advance tower/line/pattern batch, the four flow-ratio passes, retraction, VFA with its auto-adjust, input shaping frequency and damping, cornering): the model it adds, the parameters used, the presets changed, rounding warnings, refusals that leave the project alone, and how `preset_changes` "keep" and "discard" treat modified presets, including the filament tab on another slot's preset.
**Decides by:** Fails when a non-optional call errors or one of its 87 matchers misses.
- Temperature: `/params` exactly `{start: 250, end: 230, auto_scale: true}` with two rounding warnings; one `temperature_tower.drc`; `result_keys` exact; `modified` lists `nozzle_temperature`.
- Refusals: after three optional refused calls, `object_list` still holds one temperature tower and the filament preset is still modified.
- Other tests: `/params` (whole object or field), `/names` and `/objects` exact; `presets_changed` `spiral_mode` = `"1"`; `result_keys`; warnings by substring; eight runs in all, the temperature one included, slice `ok`.
- VFA fit: `/adjusted` absent at defaults; `/adjusted/layer_height` < 0.2 at end 400; absent with a warning when `auto_adjust` is false.
- Presets: "keep" on slot 2's modified preset is refused (no objects after); "discard" switches the tab from "MCP Calib PLA" and discards `filament_cost`; "keep" keeps `slow_down_layer_time` 7, which `project_new` with "discard" drops back to `"4"`; the clean-up deletes the slot and the preset.
**Not checked:**
- The refused `temperature` call with `step` (an argument the test does not take): if accepted it would make the same single temperature tower with modified presets, so the read-back after it cannot tell.
- VFA's object layer height is checked as `ne "0.2"`; an object with no `layer_height` of its own reads null and passes.
- Slices check only `outcome: ok`; nothing reads whether the G-code steps temperature, speed, pressure advance or retraction per block.
- Several preset changes are `exists` only (`nozzle_temperature`, `filament_max_volumetric_speed`), and `/presets_changed/filament/filament_slot` = 1 is a constant the reply always writes.
- Pressure advance pattern defaults are `gt 0`, not the process's acceleration and speed.
**Strength:** Strong — parameters, model names and preset outcomes are compared exactly; one refusal and the G-code's calibration steps are not checked.
**Strength:** Strong — every test's parameters, project, objects and filament changes are compared exactly with values
written out here and read back through other tools, each refusal by its code or words with the state after it, and
three towers by the values their G-code steps through; the process and printer keys beyond each row's list, and the
G-code of the other tests, are left out.
+1 -1
View File
@@ -128,7 +128,7 @@ in [TESTS.md](../TESTS.md).
**Tests:** Preferences is opened as a running `action_run` job. Then 32 `app_wait {for: no_dialog}` calls take the server's 32 blocking slots, and 32 more connections sit idle (first variant) or half-sent (second variant), filling the 64-connection cap. A `dialog_answer` on a new connection must still close the dialog and release the waits.
**Decides by:** A variant fails when `action_run` does not reply `blocked_by_dialog`, the waits are not seen holding every blocking slot, `dialog_answer` returns `isError`, or fewer than 32 waits return `satisfied: true`. A socket error crashes the script, which also exits non-zero.
- Every blocking slot taken: `app_wait` and `app_state` are observation calls, which run on the request thread, are never jobs, and each take one of the server's 32 blocking slots (`inspect_tool`, `McpCore::run`, `blocking_slots` 32). After the 32 waits start, the test calls `app_state` on a connection of its own every 0.2 s, up to 10 s, until it replies `status: "pending"` with the note "Too many calls are waiting right now; try again shortly.", the reply an observation call gets when no slot is free. A variant whose waits have not taken every slot within the 10 s fails; this read takes the place of a fixed sleep.
- Every blocking slot taken: `app_wait` and `app_state` are observation calls, which run on the request thread, are never jobs, and each take one of the server's 32 blocking slots (`inspect_tool`, `McpCore::run`, `blocking_slots` 32). After the 32 waits start, the test calls `app_state` on a connection of its own every 0.2 s, up to 10 s, until it replies `status: "pending"` with the note "Too many calls are waiting right now; try again shortly.", the reply an observation call gets when no slot is free. A variant whose waits have not taken every slot within the 10 s fails; this read takes the place of a fixed sleep. An `app_state` that finds a slot free holds it while it runs, so a wait that arrives then is itself replied `pending`: each wait is sent again every 0.2 s while it is, for up to 10 s, as the note asks, and one still `pending` after that counts as a wait that did not return `satisfied: true`.
- The holders: an idle holder sends a `ping` and reads its reply before the next one opens, so the server has accepted each of the 32. A half-sent holder sends part of a request's headers; the test gives the 32 of them 1 s.
- "recover with 32 blocked waits and 32 idle connections"
- "recover with 32 blocked waits and 32 half-sent requests"
+35 -98
View File
@@ -4,9 +4,7 @@ The design of this area's sweep tests. The rules every entry follows, the grades
in [TESTS.md](../TESTS.md).
## `test_slice_preview`
`test_slice_preview.py` · Python · takes the place of `slice_stats.json`, `preview.json`, `layers.json` and
`view_switches.json`, and of the slicing, Preview layer and plate index cases of the removed `ops_start_slice.json`,
`ops_show_layer_range.json` and `ops_select_plate.json`
`test_slice_preview.py` · Python, 758 checks · in `sweep.json` as `{"path": "test_slice_preview.py", "timeout_s": 1500}`
**Tests:** Slicing and what a slice leaves: the plates `plate_slice` and the Slice and Preview and Slice All Plates
actions slice, with no objects, with a plate that fails validation and with two plates; the statistics a slice
@@ -28,7 +26,8 @@ slices about thirty times, three of them a Benchy.
`view_type`), or `preview` null.
- `gcode(path)` (new) reads an exported G-code file. Its header: `total layer number`, `max_z_height`, `filament` (the
slots the print uses) and the `total estimated time` of the `model printing time` line, in seconds. Its layers, one
per `; CHANGE_LAYER` block in order, each with `z` (`; Z_HEIGHT:`), `height` (`; LAYER_HEIGHT:`), its tool lines (a
per `; CHANGE_LAYER` block in order, each with `z` (`; Z_HEIGHT:`), `height` (the block's first `; LAYER_HEIGHT:`;
a bridge states its own thickness in another such line further down the layer), its tool lines (a
whole line `T0` or `T1`), the line after each `; PAUSE_PRINTING` and after each `; CUSTOM_GCODE`, and for each
feature type (`; FEATURE: Sparse infill`) the XY length in mm of its extruding `G1` moves. The X1C's start G-code,
which loads the first filament with a tool line, comes before layer 1 and is not read; its end G-code, read as part
@@ -149,8 +148,10 @@ do not count (a slice of another plate, Slice All and `plate_select` each select
**Scenario: the Preview's layers**
A cube, `plate_slice`: `[0 ok]`, `"" 1 * S`, shown `1–100 (0.2–20.0)`. After each step `shown()` gives tab `preview`
and the layers the row names; a reply of the Go to layer action is `view_set`'s, with `ran`.
A cube, `plate_slice`: `[0 ok]`, `"" 1 * S`, then `view_set {layer_range: [1, 100]}`, which replies `[1, 100,
100]`: shown `1–100 (0.2–20.0)`. A slice whose top layer is as high as the last one's keeps the span the slider
showed (To settle), so the start sets it. After each step `shown()` gives tab `preview` and the layers the row names;
a reply of the Go to layer action is `view_set`'s, with `ran`.
| # | Step | Reply | Shown after |
|---|---|---|---|
@@ -225,7 +226,7 @@ the row.
| 9 | `... {action: "reset"}` | none | |
| 10 | `... {action: "smooth", quality: 0.3}` | none | refused, "quality goes with action adaptive" |
| 11 | `view_set {canvas: "assemble"}`, `... {action: "adaptive"}`, `view_set {canvas: "3d"}` | none | the adaptive call refused, "Leave the assemble view first" |
| 12 | `object_set_height_ranges {object: 0, ranges: [{min_z: 0, max_z: 20}, {min_z: 20, max_z: 48}]}`, `layer_height` 0.12 on the first and 0.28 on the second | none | `object_list` ranges `[0, 20] {layer_height "0.12"}` and `[20, 48] {layer_height "0.28"}` |
| 12 | `object_set_height_ranges {object: 0, ranges: [{min_z: 0, max_z: 20}, {min_z: 20, max_z: 48}]}`, `layer_height` 0.12 on the first and 0.28 on the second | none | `object_list` ranges `[0, 20] {layer_height "0.12", extruder "0"}` and `[20, 48] {layer_height "0.28", extruder "0"}` |
| 13 | `... {action: "smooth"}` | `min_height` 0.12, `max_height` 0.28 | reply `warnings` holding "decides its layer heights": smooth starts from the ranges' heights |
| 14 | `... {action: "adaptive", quality: 0}` | `min_height` 0.12 | the ranges stay: `[20, 48]` still `layer_height "0.28"` |
| 15 | `project_save` to a new file, `project_new`, `project_open` of the file | `min_height` 0.12, more than 100 points | the profile is kept in the project file |
@@ -289,10 +290,11 @@ at the export's path. Those of plate 5 and -1 say "Plate 5 does not exist (the p
**Scenario: view switches**
A 30 mm sphere "ball" (`object_add_primitive {shape: "sphere", size: [30]}`), selected, and `view_set {camera:
"iso"}`. `app_state.view` is written as the switches that are on; at the start, those of a fresh configuration
folder: `gridlines`, `axes`, `navigator` and `gcode_window`, with `projection` `perspective`, `section.on` false,
`sidebar_collapsed` and `legend_collapsed` false. C0 is `capture()` at the start. After every step `app_state.view` is
compared with the row whole, and the reply gives the switch's value as the row does.
"iso", orbit: [0, -25]}`, the iso direction lowered to 20° above the bed (To settle). `app_state.view` is written as
the switches that are on; at the start, those of a fresh configuration folder: `gridlines`, `axes`, `navigator` and
`gcode_window`, with `projection` `perspective`, `section.on` false, `sidebar_collapsed` and `legend_collapsed` false.
C0 is `capture()` at the start. After every step `app_state.view` is compared with the row whole, and the reply gives
the switch's value as the row does.
| # | Step | View after | Also checked |
|---|---|---|---|
@@ -321,9 +323,8 @@ compared with the row whole, and the reply gives the switch's value as the row d
**Scenario: the app's account, network plug-in and configuration folder**
The configuration folder is compared with the folder the app was launched on, on every platform. That takes the
place of the replay's check that it is not a person's own folder, which it built as `APPDATA` (or `~`) plus
`OrcaSlicer` and which could fail only on Windows.
The configuration folder is compared with the folder the app was launched on, on every platform, rather than
checked not to be a person's own folder (`APPDATA` or `~` plus `OrcaSlicer`), which could fail only on Windows.
| # | Step | Checked |
|---|---|---|
@@ -362,12 +363,28 @@ place of the replay's check that it is not a person's own folder, which it built
only "more than 100" on 128 layers.
- The top of the speed colour range with travel shown is 500, the X1C's `travel_speed` in mm/s; the colour ranges
count travel only while the legend shows it. With travel hidden, every extrusion speed is lower.
- A new slice keeps the layer slider's span when its top layer is as high as the last print's and the slider was off
its ends (`Preview::update_layers_slider()`, `main`'s code since 1555904bef), so after the statistics and tables
scenarios a cube's slice can show `1–5`. That is the app's own behaviour, not a bug: the layers scenario sets
`[1, 100]` after its slice instead of expecting it.
- The exported toolpaths' vertices lie within half a layer of the layers shown; the bounds allow a whole layer.
- The toolpaths an export writes right after a layer change (the layers, step 17). A bug in this branch's code, left
for a fix: `Ops::export_toolpaths_obj()` (`ExportOps.cpp`, not on `main`) writes the G-code viewer's visible range,
which takes the layer slider's values only when the canvas next draws (`GLCanvas3D::_apply_gcode_sliders()`, commit
39705d7bb9, not on `main`). `view_set {layer_range: [20, 25]}` followed at once by the export writes every layer
(z 0.1 to 20.1); after a canvas screenshot it writes 3.9 to 5.1. The fix: apply the pending slider values to the
viewer before the export (a public `GLCanvas3D::apply_gcode_sliders()` called from `Ops::export_toolpaths_obj()`).
The row expects the fixed behaviour.
- A display switch turned back draws the 3D view as before it was changed, so the capture is byte-identical: every
check that a capture is C0 or C1 (view switches, steps 2, 3, 4, 5, 7, 11 and 19). If a switch leaves a trace (the
navigator's or another ImGui window's position), that check falls back to "differs from the capture taken with the
switch changed". The overhang highlight is visible from the iso view on the sphere's lower half, between its equator and about
55° below it.
switch changed".
- The camera of the view switches. The overhang highlight colours a face whose normal points more than 31° below the
horizontal (`support_threshold_angle` 30, plus the one degree `GLVolumeCollection::get_selection_support_normal_z()`
adds, `main`'s code). From the iso view, 45° above the bed, the part of the sphere facing the camera reaches only 45°
below its equator, so the highlight is a band on the sphere's rim too thin to change a pixel: the capture with
overhangs on is byte-identical to C0. From 20° above the bed the band from 31° to 70° below the equator faces the
camera and shows, and every other switch shows too. The setup lowers the camera so.
- The start of the view switches: `AppConfig`'s defaults for a configuration folder the harness seeds without these
keys. The network plug-in's start: not installed on the sweep's fresh datadir, so neither loaded nor failed.
- The sidebar's default width is 39 em (`AuiMgr::sidebar_pane_info()`), which depends on the display's scale or font,
@@ -421,85 +438,5 @@ place of the replay's check that it is not a person's own folder, which it built
- The notifications in `plate_slice`'s reply: the validation error is checked through the plate's `error`.
- What the 3D view looks like: captures are compared only with each other.
## Replays this area replaces
Each leaves the sweep, with its entry, in the commit that adds the tests above.
### `slice_stats`
`tests/slice_stats.json` · replay, 19 steps, 4 expects, 0 optional
**Tests:** `plate_slice`'s statistics: layers, max Z, filament changes, total grams and each slot's model, support, flush and prime-tower grams, for one cube on filament 1 of two, then with a second cube put on filament 2 by the canvas's `2` key.
**Decides by:** Fails when a call errors or one of its 25 matchers misses.
- One colour: 128 layers; `max_z` in (25.5, 25.7); 0 filament changes; exactly two slot rows (slot 1, slot 2); slot 1 model > 0 with flush and tower 0; slot 2 g = 0.
- Key: `keyboard_press` to `OrcaSceneCanvas` `/to` = `wxGLCanvas`.
- Two colours: 128 layers; filament changes > 100; both slots' model, flush and tower grams > 0; slot 2 support = 0.
**Not checked:**
- The `2` key's effect is never read directly; it shows only through slot 2's model grams.
- The two-colour figures are lower bounds (`gt 100` changes where every layer changes, `gt 0` grams); `filament_g` and slot 1's support are not read in the second slice.
- The arrange step has no expect.
**Strength:** Strong — the one-colour breakdown is exact, and the two-colour slice fails if flush, tower or slot 2's model goes missing.
### `preview`
`tests/preview.json` · replay, 52 steps, 21 expects, 0 optional
**Tests:** `plate_slice_stats` and `app_state.preview` on a sliced 25.6 mm cube: the summary, feature and layer tables with paging, the object row, and the legend state as `view_set` changes rows, layer (by number and by height), view type and time mode; that nothing reports the selected plate's toolpaths while the Preview still holds another plate's; and the same reads on the cube's exported G-code opened for viewing.
**Decides by:** Fails when a call errors or one of its 80 matchers misses.
- Tables: 128 layers; layer 1 at z 0.2; layer 5 at z 1.0 with height 0.2; `next_offset` 5; the last page is layer 128 at z 25.6 with no `next_offset`; `include` filtering (`/features`, `/view` absent when not asked); `Outer wall` percent in (0, 100); times, grams and mm `gt 0`.
- Legend and view: view type, range [1, 128], `Sparse infill`/`travel` visibility after each change, feature rows shown again after Line Type is picked; `layer_z` 1.0 gives layer 5, 1.05 gives layer 6 at z 1.2.
- `app_state.preview`: plate, layers, z, layer count and view type follow `view_set`.
- Plates: both slice `ok`; plate 0 shown reports plate 0; plate 1 selected in Prepare gives `/preview` null and `plate_slice_stats` `/view` null with the "has not loaded this plate's toolpaths" note; once shown, plate 1 with no note.
- G-code view: 128 layers in `app_state` and the stats, with features and summary present.
**Not checked:**
- The G-code section's claim that its plate "is never marked sliced": no step reads `sliced`.
- `time_mode` is set to `normal`, the mode already shown, so switching modes is never exercised.
- Times, grams, travel and colour ranges are `gt 0`; only their presence is shown.
- `legend.png` is saved and never compared.
**Strength:** Strong — layer counts, heights, paging and legend state are compared exactly and read two ways.
### `layers`
`tests/layers.json` · replay, 112 steps, 128 expects, 14 optional
**Tests:** Height range modifiers (`object_set_height_ranges`, `settings_set` target `height_range`), variable layer height profiles (`object_set_variable_layer_height` adaptive, smooth, reset), and a plate's layer G-codes (`plate_set_custom_gcode`), each with undo, refusals, a slice and a 3MF round trip.
**Decides by:** Fails when a non-optional call errors or an expect misses.
- Height ranges: the reply's ranges sorted with `max_z`/`min_z` 10, `layer_height` "0.2", `extruder` "0", `/height` 20 ± 0.01 and no `/warnings`; `settings_set` `/applied` and `/height_range` exact; `object_list` holds "40%" and "0.1" and no third range; the object's own `sparse_infill_density` stays null.
- Undo: one undo reverts only the last range setting; the same ranges again keep their settings and add no undo step (the next undo reverts `layer_height` to "0.2").
- Slices: `plate_slice` `/status` "done" and outcome "ok"; the Preview's `/layers/2` (layer count) is 149–151 with the ranges and exactly 100 after `[]` removes them.
- Range refusals (optional overlap, 0.5 mm layer, filament 9, `enable_support`, empty range) are followed by `object_list` showing range 0 still ending at 10 at "0.2" with extruder "0", no `enable_support`, range 1 at "0.1", no range 2.
- Variable layer height: adaptive `points` > 250, `min_height` < 0.2, `max_height` > 0.2, tab back to "prepare"; quality 0 gives > 380 points, 1 < 320; sliced layer count > 245; smooth `max_height` < 0.28, undo restores exactly 0.28; reset removes the profile and a second reset adds no undo step (undo brings the smoothed profile back); refusals leave no profile; over ranges smooth gives min 0.12, max 0.28 and a warning containing "decides its layer heights".
- Layer G-codes: before a slice the optional call leaves tab "prepare" and nothing slicing; from Prepare the reply's plate, 100 layers, `changed`, and each code's type, layer, z and gcode are exact (pause at layer 26 z 5.2, custom at 51 z 10.2), with the "slice it again" note, and the app shows the Preview with the project dirty; the same code again gives `changed` false; remove plus add in one call; after five optional refusals a repeat call shows the list unchanged; a stale plate in Prepare leaves tab and slicing alone; a filament change at layer 76 z 15.2 filament 2; `clear` gives `[]`.
- 3MF round trips: reopened ranges keep "40%", "0.1" and extruder "2"; the profile keeps min 0.12 and > 100 points; reopened and resliced layer G-codes keep "M104 S220" and filament 2.
**Not checked:**
- Refusals that would change nothing if accepted cannot be told from success: removing at layer 30 where nothing is, and the code for plate 1, which the follow-up (plate 0 only) does not read. No refusal's reason is asserted.
- The range settings and layer G-codes never reach a checked slice result: 40 % infill, the extruder-2 range and the pause, custom and filament-change codes are only followed by an "ok" slice, not looked for in the G-code or Preview.
- Adaptive profiles and their slices are checked with bounds (point counts, layer count > 245), not exact values.
- The filament change's `color` is checked with `exists` only.
**Strength:** Strong — each edit, undo, refusal and 3MF reopen is read back with exact values; only the adaptive algorithm's counts are bounds.
### `view_switches`
`tests/view_switches.json` · replay, 67 steps, 60 expects, 0 optional
**Tests:** `view_set` outside the Design tab, each state read from its reply and from `app_state.view`: sidebar collapse and width, every Prepare display switch, projection and section view, and in the Preview the legend fold and the G-code window; a cube placed by numbers in the middle of plate 1; and `app_state`'s account, network plug-in and configuration folder.
**Decides by:** Fails when a call errors, an inline `script_run` raises, or one of its 81 matchers misses.
- Switches: `labels`, `overhangs`, `outline`, `wireframe`, `gridlines`, `axes` and `navigator` each true then false in the reply and `app_state`; three at once; projection orthographic (camera `ortho`) and back; `section/on`; `legend_collapsed`; `gcode_window`; a fold asked with a view type stays folded.
- Sidebar width (script): start > 100; start + 150 is reported and read back; `default` returns to the start width.
- Placement: after `plate_add` (origin and size > 0), the script's cube is the only object on plate 1 and not on plate 0; `plate_list` counts 1 and 1.
- App info: signed in to neither cloud; `network_plugin` fields exist; the log lies under `config_folder`, which is not the personal folder.
**Not checked:**
- `personal` is built as `APPDATA` (or `~`) plus `OrcaSlicer`, the real folder only on Windows; on macOS and Linux the `personal: false` check cannot fail.
- The `default` width is taken to be the start width, not a known default: it fails on a datadir that starts wider, and passes if the default itself changed.
- The placement script's x/y are not compared with the object's offset; only the plate it lands on.
- `network_plugin` fields are `exists` only.
- That picking a view type alone unfolds the legend is not tested; only that a fold asked with it is kept.
**Strength:** Strong — every switch is set both ways and read back from two sources.
**Strength:** Strong — what the profile fixes (layers, heights, slots, codes, switches) is compared exactly and read
back from the G-code or the 3MF; what the slicer works out (grams, times, adaptive profiles) is held to stated bounds.
+3 -2
View File
@@ -424,8 +424,9 @@ into `{"error": ...}`, and the check that follows judges it.
`page_buttons`.
- A click queued behind a busy page is never run: the count of `ok` lines stays the same.
- "and the panel's own page never saw that click": the dock panel's log, read from `widget_list`, is exactly
one ping (`label "ping"`, from the click "its page, whose CSP forbids eval, takes a click") before the refused
click and still exactly that after it. A log that is not found reads as no line, which fails.
two pings (`label "ping ping"`, from the click "its page, whose CSP forbids eval, takes a click" and the click
on Ping that ends the press held on the window's pad) before the refused click and still exactly that after
it. A log that is not found reads as no line, which fails.
- Page changes and navigation:
- `page.changed`, `added` and `partial` must match.
- `navigated` URLs must end with `#bottom`, `#top`, `#evaluated` and `#orca-token=REDACTED&view=2`.
+42 -11
View File
@@ -5,13 +5,14 @@ replay or a script can't act on them.
tools/mcp/orca_mcp.py launch
tools/mcp/test_action_replay_hidden.py
With Action Replay open: widget_list lists no window for it, a window screenshot still works,
webview_run_javascript without a target behaves as it did before the window opened (it must not find a second
web view), and keyboard_press without a target never reaches its web view. With the Run Script panel shown on
Prepare: widget_list lists no more web views than before, webview_run_javascript without a target behaves as
before, keyboard_press without a target reaches the 3D view, a window screenshot works and an agent's script_run
finishes. replay_run still runs the smoke test, and a replay nesting an inline replay_run passes. Exits
0 when every check passes.
Each window is first seen up: window_list lists Action Replay as hidden, and the 3D view is shorter once the Run
Script panel docks under it. With Action Replay open: widget_list lists no window or dialog for it, while it lists
the main window as such a line, a window screenshot still works, webview_run_javascript without a target behaves
as it did before the window opened (it must not find a second web view), and keyboard_press without a target goes
to the 3D view, not to a page. With the Run Script panel shown on Prepare: widget_list lists no more web views
than before, webview_run_javascript without a target behaves as before, keyboard_press without a target reaches
the 3D view, a window screenshot works and an agent's script_run finishes. replay_run still runs the smoke test,
and a replay nesting an inline replay_run passes. Exits 0 when every check passes.
"""
import os
@@ -24,6 +25,7 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import orca_mcp # noqa: E402
HERE = os.path.dirname(os.path.abspath(__file__))
SHOW_LIMIT_S = 10 # from the action that opens a window until it is seen up
def main():
@@ -43,31 +45,60 @@ def main():
_snap, texts = client.call_with_text("widget_list")
return len(re.findall(r"\bwebview\b", texts[0] if texts else ""))
def canvas_height():
"""The 3D view's height, from its line in widget_list, or None when it is not listed."""
_snap, texts = client.call_with_text("widget_list")
found = re.search(r'canvas "OrcaSceneCanvas"[^\n]*@-?\d+,-?\d+ \d+x(\d+)', "\n".join(texts))
return int(found.group(1)) if found else None
def within(limit, condition):
"""Whether `condition()` holds within `limit` s, asked every 0.2 s."""
deadline = time.monotonic() + limit
while not condition():
if time.monotonic() > deadline:
return False
time.sleep(0.2)
return True
def action_replay_listed():
return any(w.get("title") == "Action Replay" and w.get("hidden") is True
for w in client.call("window_list").get("items", []))
client.call("project_new", discard_changes=True)
client.call("view_set", tab="home")
before = eval_outcome()
client.call("action_run", id="orca_command:open_action_replay:orca")
check("Action Replay opens", within(SHOW_LIMIT_S, action_replay_listed),
f"window_list lists no hidden Action Replay window {SHOW_LIMIT_S} s after the action")
time.sleep(1.0) # let its web view load
snap, texts = client.call_with_text("widget_list")
tree = texts[0] if texts else ""
# The File menu's "Action Replay..." item is listed; the window must not be.
check("widget_list lists no Action Replay window", 'window "Action Replay"' not in tree)
check("widget_list still lists the main window", "(MainFrame)" in tree)
# The File menu's "Action Replay..." item is listed; the window must not be. The main window's line is the
# control: the tree words a window as its role and its title in quotes.
check("widget_list lists no Action Replay window", not re.search(r'\b(window|dialog) "Action Replay"', tree))
check("widget_list still lists the main window", re.search(r'\bwindow "[^"\n]+" \(MainFrame\)', tree))
check("a window screenshot works", client.call("window_screenshot", target="main").get("path"))
check("webview_run_javascript without a target behaves as before", eval_outcome() == before, f"{before} / {eval_outcome()}")
client.call("view_set", tab="prepare")
client.call("action_run", id="orca_command:open_action_replay:orca") # raised again, so it has the focus
# A key that reached a page replies with what the page did; the focus left in a window the tools don't see is
# no target, so the key goes to the shown 3D view.
key = client.call("keyboard_press", keys="Escape")
check("a key without a target never goes to Action Replay's web view", "webview" not in str(key.get("to", "")).lower(), key)
check("a key without a target never goes to Action Replay's web view",
"page" not in key and "canvas" in str(key.get("to", "")).lower(), key)
# The Run Script panel, docked under the 3D view of Prepare.
client.call("view_set", tab="prepare")
nodes_before = webview_nodes()
prepare_eval = eval_outcome()
height = canvas_height()
client.call("action_run", id="orca_command:toggle_run_script_panel:orca")
check("the Run Script panel shows",
height is not None and within(SHOW_LIMIT_S, lambda: (canvas_height() or height) < height),
f"the 3D view is {canvas_height()} high {SHOW_LIMIT_S} s after the toggle, {height} before")
time.sleep(1.0) # let its web view load
check("widget_list lists no node of the Run Script panel", webview_nodes() == nodes_before, f"{nodes_before} / {webview_nodes()}")
check("webview_run_javascript without a target behaves as before the panel", eval_outcome() == prepare_eval, f"{prepare_eval} / {eval_outcome()}")
+7 -4
View File
@@ -240,14 +240,17 @@ def main():
# ---- An order of objects names each of the plate's objects once ----
client.call("project_new", discard_changes=True)
client.call("view_set", tab="prepare")
for _ in range(2):
client.call("object_add_primitive", shape="cube", size=[20, 20, 20])
# Named apart, so that an order that changed shows in the names.
for name in ("first", "second"):
client.call("object_add_primitive", shape="cube", size=[20, 20, 20], name=name)
client.call("object_select", none=True)
names = lambda: [o["name"] for o in client.call("object_list")["plates"][0]["objects"]]
before = names()
check("two cubes, first and second", names() == ["first", "second"], names())
refused("object_order with an order that leaves out an object of the plate is refused, naming it", "object_order",
{"plate": 0, "order": [1]}, "leaves out objects of plate 0: 0", "order_misses_object")
check("and leaves the order as it was", names() == before, (before, names()))
check("and leaves the order as it was", names() == ["first", "second"], names())
client.call("object_order", plate=0, order=[1, 0])
check("a full order is taken", names() == ["second", "first"], names())
failed = [c for c in checks if not c[1]]
for name, ok, detail in checks:
+588
View File
@@ -0,0 +1,588 @@
#!/usr/bin/env python3
"""The Calibration menu's tests through calibration_generate_test, as the test_calibration entry of
tools/mcp/test-entries/presets.md designs them.
tools/mcp/orca_mcp.py launch
tools/mcp/test_calibration.py
Every test and method: the project it makes, the parameters it uses, the presets and objects it changes, the warnings
for values it rounds or the printer may not take, and the refusals that leave the project and presets as they were;
preset_changes "keep" and "discard", including the filament tab on another slot's modified preset; and, through the
exported G-code, that the temperature, pressure advance and retraction towers change their value band by band. After
each call the test reads the project, the objects and the presets back with other tools and compares them with the
values the entry writes out. It runs on the harness's default printer, the Bambu Lab X1 Carbon 0.4, and exits 0 when
every check passes.
"""
import os
import re
import sys
import tempfile
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import orca_mcp # noqa: E402
from checks import Checks, refusal, run # noqa: E402
X1C = "Bambu Lab X1 Carbon 0.4 nozzle"
STD = "0.20mm Standard @BBL X1C"
PLA = "Bambu PLA Basic @BBL X1C"
SHORT = {"X1C": X1C, "Std": STD, "PLA": PLA}
DISCARD = {"discard_changes": True, "preset_changes": "discard"}
FILAMENT_ADD = "orca_command:filament_add:orca"
TEMPERATURE_KEYS = ["nozzle_temperature", "nozzle_temperature_initial_layer"]
class Every:
"""A value with one entry per extruder or variant, each entry `value`: Every("0") equals "0,0"."""
def __init__(self, value):
self.value = str(value)
def __eq__(self, other):
if not isinstance(other, str) or not other:
return False
return all(same_number(entry, self.value) for entry in other.split(","))
def __repr__(self):
return f"every entry {self.value}"
def same_number(a, b):
try:
return float(a) == float(b)
except ValueError:
return a == b
def whole(number):
"""A number as the pattern's object names write it: 200, not 200.0."""
return str(int(number)) if float(number) == int(number) else str(number)
def split_top(text):
"""`text` split at the ", " that stand outside brackets."""
parts, depth, start = [], 0, 0
for i, ch in enumerate(text):
depth += {"[": 1, "]": -1}.get(ch, 0)
if depth == 0 and text.startswith(", ", i):
parts.append(text[start:i])
start = i + 2
parts.append(text[start:])
return parts
def S(text):
"""A selection as the entry writes it: 'X1C | Std | PLA, MCP Calib PLA[filament_cost 22]' is the X1C, Std, and
two filament slots, the second's preset with filament_cost edited to 22. Only the filaments' edits are kept: the
test compares the printer and the process by name."""
printer, process, filaments = text.split(" | ")
def preset(s):
m = re.match(r"^(.*?)(?:\[(.*)\])?$", s)
edits = {}
if m.group(2):
for pair in split_top(m.group(2)):
key, _, value = pair.partition(" ")
edits[key] = value.strip('"')
return SHORT.get(m.group(1), m.group(1)), edits
return {"printer": preset(printer)[0], "process": preset(process)[0],
"filaments": [dict(zip(("name", "edits"), preset(f))) for f in split_top(filaments)]}
def pla(edits):
"""The selection `X1C | Std | PLA` with PLA's unsaved keys and values `edits`."""
return {"printer": X1C, "process": STD, "filaments": [{"name": PLA, "edits": dict(edits)}]}
def gcode_layers(path):
"""The lines of an exported G-code file after its first `; Z_HEIGHT:` line."""
with open(path, encoding="utf-8", errors="replace") as f:
lines = f.read().splitlines()
first = next(i for i, line in enumerate(lines) if line.startswith("; Z_HEIGHT:"))
return lines[first + 1:]
def in_a_row(values):
"""`values` with repeats in a row dropped."""
return [v for i, v in enumerate(values) if i == 0 or v != values[i - 1]]
def flow_offset(name):
"""The number a flow ratio object's name ends in, "m" for minus: flowrate_m0.01 is -0.01."""
m = re.fullmatch(r"flowrate_(m?)([0-9.]+)", name)
assert m, name
return -float(m.group(2)) if m.group(1) else float(m.group(2))
class CalibrationTest:
def __init__(self, client, folder):
self.c = client
self.t = Checks()
self.folder = folder
# ---- Calls and reads ----
def run(self, tool, **args):
return run(self.c, tool, **args)
def value(self, type_, key, preset=None, slot=None):
args = {"type": type_, "keys": [key], "include_meta": False}
if preset is not None:
args["preset"] = preset
if slot is not None:
args["filament_slot"] = slot
return self.c.call("settings_get", **args)["items"][0]["value"]
def selection(self):
"""The printer, the process and each slot's filament by name, with the unsaved keys of each slot's filament
and their whole values."""
presets = self.c.call("app_state")["presets"]
filaments = []
for slot, name in enumerate(presets["filaments"], 1):
keys = []
for item in self.c.call("settings_get", type="filament", compare=":saved", filament_slot=slot,
limit=500)["items"]:
if item["key"] not in keys:
keys.append(item["key"])
filaments.append({"name": name, "edits": {k: self.value("filament", k, slot=slot) for k in keys}})
return {"printer": presets["printer"], "process": presets["process"], "filaments": filaments}
def objects(self):
listing = self.c.call("object_list", limit=500)
return [{"name": o["name"], "height": o["bbox"]["size"][2]} for p in listing["plates"] for o in p["objects"]]
def own(self, obj, key):
return self.c.call("settings_get", target="object", object=obj, keys=[key])["items"][0]["value"]
def project_name(self):
return self.c.call("app_state")["project"]["name"]
def selection_is(self, label, want):
self.t.equal(f"{label}: the selection", self.selection(), want)
def refused(self, label, call, code=None, words=None):
"""Checks.refused, giving the refusal's details as well as its text."""
caught = {}
def wrapped():
try:
return call()
except orca_mcp.McpError as e:
caught["text"], caught["details"] = refusal(e)
raise
self.t.refused(label, wrapped, code=code, words=words)
return caught.get("text", ""), caught.get("details", {})
def slice(self, label, export=None):
"""plate_slice and a check that it ended ok; with `export`, the G-code written to that new file in the test's
folder, whose path it returns."""
reply = self.run("plate_slice")
self.t.equal(f"{label}: the slice", [p.get("outcome") for p in reply.get("plates", [])], ["ok"])
if export is None:
return None
path = os.path.join(self.folder, export)
self.run("project_export", format="gcode", path=path)
return path
def generate(self, label, args, params, project=None, names=None, heights=None, changes=None, sets=None,
result_keys=None):
"""Makes the test with `args`, discarding the project's and the presets' changes, and checks what the row
fixes: the reply's params whole; project, read back from app_state; names, read back from object_list, with
their heights to 0.01 where given; the filament's changes whole in the reply and in the selection; each key
`sets` lists, read with value(); and result_keys."""
t = self.t
reply = self.run("calibration_generate_test", **DISCARD, **args)
if params is not None:
t.equal(f"{label}: params", reply.get("params"), params)
if project is not None:
t.equal(f"{label}: the reply's project", reply.get("project"), project)
t.equal(f"{label}: the project's name", self.project_name(), project)
if names is not None:
t.equal(f"{label}: the reply's names", reply.get("names"), names)
objects = self.objects()
t.equal(f"{label}: the objects", [o["name"] for o in objects], names)
if heights is not None:
t.near(f"{label}: the objects' heights", [o["height"] for o in objects], heights, 0.01)
if changes is not None:
filament = reply.get("presets_changed", {}).get("filament", {})
t.equal(f"{label}: the filament's changes", {k: filament.get(k) for k in ("name", "changes")},
{"name": PLA, "changes": changes})
self.selection_is(label, pla(changes))
for (type_, key), want in (sets or {}).items():
t.equal(f"{label}: sets {type_} {key}", self.value(type_, key), want)
if result_keys is not None:
t.equal(f"{label}: result_keys", reply.get("result_keys"), result_keys)
return reply
# ---- Scenarios ----
def temperature(self):
s = "temperature"
t = self.t
self.run("project_new", **DISCARD)
self.selection_is(f"{s} 1", S("X1C | Std | PLA"))
t.equal(f"{s} 1: no objects", self.objects(), [])
reply = self.run("calibration_generate_test", test="temperature", start=252, end=232)
t.equal(f"{s} 2: the reply's project", reply.get("project"), "Nozzle temperature test")
t.equal(f"{s} 2: params", reply.get("params"), {"start": 250, "end": 230, "auto_scale": True})
t.equal(f"{s} 2: warnings", reply.get("warnings"),
["start 252 °C rounded down to 250 °C, the tower's 5 °C blocks",
"end 232 °C rounded down to 230 °C, the tower's 5 °C blocks"])
t.equal(f"{s} 2: the reply's names", reply.get("names"), ["temperature_tower.drc"])
filament = reply.get("presets_changed", {}).get("filament", {})
t.equal(f"{s} 2: the filament's changes", {k: filament.get(k) for k in ("name", "changes")},
{"name": PLA, "changes": {"nozzle_temperature": "250,250", "nozzle_temperature_initial_layer": "250,250"}})
t.equal(f"{s} 2: result_keys", reply.get("result_keys"), {"type": "filament", "keys": TEMPERATURE_KEYS})
t.equal(f"{s} 2: modified", reply.get("modified", {}).get("filament", {}).get("keys"), TEMPERATURE_KEYS)
t.equal(f"{s} 2: the project is dirty", self.c.call("app_state")["project"]["dirty"], True)
after2 = S("X1C | Std | PLA[nozzle_temperature 250,250, nozzle_temperature_initial_layer 250,250]")
def as_after_2(label):
t.equal(f"{label}: the project's name", self.project_name(), "Nozzle temperature test")
objects = self.objects()
t.equal(f"{label}: the objects", [o["name"] for o in objects], ["temperature_tower.drc"])
t.near(f"{label}: the tower's height, five 10 mm blocks", [o["height"] for o in objects], [50], 0.01)
t.equal(f"{label}: the tower's own layer height", self.own(0, "layer_height"), "0.2")
self.selection_is(label, after2)
as_after_2(f"{s} 2")
path = self.slice(f"{s} 3", "temperature.gcode")
temps = [float(m.group(1)) for line in gcode_layers(path)
if (m := re.match(r"M104 S([0-9.]+)", line))]
t.equal(f"{s} 3: the tower's temperatures, block by block", in_a_row([v for v in temps if v != 0]),
[250, 245, 240, 235, 230])
text, details = self.refused(f"{s} 4: refused while the presets are modified",
lambda: self.c.call("calibration_generate_test", test="max_volumetric",
discard_changes=True),
words="Presets are modified")
t.check(f"{s} 4: the refusal names preset_changes", "preset_changes" in text, text)
t.equal(f"{s} 4: the refusal's modified keys", details.get("modified", {}).get("filament", {}).get("keys"),
TEMPERATURE_KEYS)
as_after_2(f"{s} 4")
_, details = self.refused(f"{s} 5: an argument the test does not take is refused",
lambda: self.c.call("calibration_generate_test", test="temperature", step=5,
**DISCARD),
words="step does not apply to temperature")
t.equal(f"{s} 5: the arguments it takes", details.get("takes"), ["start", "end", "auto_scale", "test_model"])
as_after_2(f"{s} 5")
self.refused(f"{s} 6: a step past the range is refused",
lambda: self.c.call("calibration_generate_test", test="pressure_advance", start=0.01, end=0.05,
step=0.051, **DISCARD),
words="pressure_advance needs start >= 0, step >= 0.001 and end >= start + step; "
"got start 0.01, end 0.05, step 0.051")
as_after_2(f"{s} 6")
self.refused(f"{s} 7: refused without discard_changes",
lambda: self.c.call("calibration_generate_test", test="retraction", preset_changes="discard"),
code="unsaved_changes")
as_after_2(f"{s} 7")
def other_tests(self):
s = "other tests"
t = self.t
self.generate(f"{s}: the start", {"test": "temperature"}, {"start": 230, "end": 190, "auto_scale": True},
changes={"nozzle_temperature": "230,230", "nozzle_temperature_initial_layer": "230,230"})
label = f"{s} 1"
reply = self.generate(label, {"test": "max_volumetric", "end": 15}, {"start": 5, "end": 15, "step": 0.5},
project="Max volumetric speed test", names=["SpeedTestStructure.drc"], heights=[22],
changes={"filament_max_volumetric_speed": "200,200", "slow_down_layer_time": "0"},
sets={("filament", "filament_max_volumetric_speed"): "200,200",
("filament", "slow_down_layer_time"): "0", ("process", "spiral_mode"): "1"},
result_keys={"type": "filament", "keys": ["filament_max_volumetric_speed"]})
t.equal(f"{label}: discarded", reply.get("discarded", {}).get("filament"), {"name": PLA, "keys": TEMPERATURE_KEYS})
t.equal(f"{label}: the temperature is the preset's again", self.value("filament", "nozzle_temperature"), "220,220")
self.slice(label)
label = f"{s} 2"
self.generate(label, {"test": "pressure_advance", "end": 0.06},
{"method": "tower", "start": 0, "end": 0.06, "step": 0.002}, project="Pressure Advance Test",
names=["tower_with_seam.drc"], changes={"slow_down_layer_time": "1"},
sets={("filament", "slow_down_layer_time"): "1"},
result_keys={"type": "filament", "keys": ["enable_pressure_advance", "pressure_advance"]})
path = self.slice(label, "pressure_advance.gcode")
ks = [float(m.group(1)) for line in gcode_layers(path) if (m := re.match(r"M900 K([0-9.]+)", line))]
t.near(f"{label}: the tower's pressure advance, band by band", in_a_row(ks),
[round(0.002 * i, 6) for i in range(31)], 0.0001)
self.generate(f"{s} 3", {"test": "pressure_advance", "method": "line", "print_numbers": False},
{"method": "line", "start": 0, "end": 0.1, "step": 0.002, "print_numbers": False},
project="Pressure Advance Test", names=["pressure_advance_test.drc"], changes={},
sets={("process", "wipe_inward"): "0", ("process", "retract_after_outer_wall"): "0"})
pattern_changes = {"filament_retract_when_changing_layer": Every("0"), "filament_wipe": Every("0")}
pattern_sets = {("filament", "filament_retract_when_changing_layer"): Every("0"),
("filament", "filament_wipe"): Every("0"), ("printer", "wipe"): Every("0"),
("printer", "retract_when_changing_layer"): Every("0")}
label = f"{s} 4"
self.generate(label, {"test": "pressure_advance", "method": "pattern", "accelerations": [1000, 2000],
"speeds": [50, 100]},
{"method": "pattern", "start": 0, "end": 0.08, "step": 0.005, "accelerations": [1000, 2000],
"speeds": [50, 100]},
project="Pressure Advance Test",
names=["pa_pattern_50_1000", "pa_pattern_100_1000", "pa_pattern_50_2000", "pa_pattern_100_2000"],
changes=pattern_changes, sets=pattern_sets,
result_keys={"type": "filament", "keys": ["enable_pressure_advance", "pressure_advance",
"adaptive_pressure_advance",
"adaptive_pressure_advance_model"]})
self.slice(label)
label = f"{s} 5"
reply = self.generate(label, {"test": "pressure_advance", "method": "pattern"}, None,
project="Pressure Advance Test", changes=pattern_changes, sets=pattern_sets)
a = float(self.value("process", "outer_wall_acceleration").split(",")[0])
v = float(self.value("process", "outer_wall_speed").split(",")[0])
t.check(f"{label}: the process's outer wall acceleration and speed are above 0", a > 0 and v > 0, (a, v))
t.equal(f"{label}: params, the pattern's defaults the process's", reply.get("params"),
{"method": "pattern", "start": 0, "end": 0.08, "step": 0.005, "accelerations": [a], "speeds": [v]})
names = [f"pa_pattern_{whole(v)}_{whole(a)}"]
t.equal(f"{label}: the reply's names", reply.get("names"), names)
t.equal(f"{label}: the objects", [o["name"] for o in self.objects()], names)
label = f"{s} 6"
reply = self.generate(label, {"test": "flow_ratio"}, {"method": "yolo", "top_surface_pattern": "archimedeanchords"},
project="Orca YOLO Flow Calibration",
names=["flowrate_0", "flowrate_0.01", "flowrate_0.02", "flowrate_0.03", "flowrate_0.04",
"flowrate_0.05", "flowrate_m0.01", "flowrate_m0.02", "flowrate_m0.03",
"flowrate_m0.04", "flowrate_m0.05"],
changes={}, sets={("process", "layer_height"): "0.2"},
result_keys={"type": "filament", "keys": ["filament_flow_ratio"]})
self.flow_ratios(label, lambda m: (0.98 + m) / 0.98, "archimedeanchords")
self.slice(label)
label = f"{s} 7"
self.generate(label, {"test": "flow_ratio", "method": "yolo_perfectionist"},
{"method": "yolo_perfectionist", "top_surface_pattern": "archimedeanchords"},
project="Orca YOLO Flow Calibration - Perfectionist version",
names=["flowrate_0", "flowrate_0.005", "flowrate_0.01", "flowrate_0.015", "flowrate_0.02",
"flowrate_0.025", "flowrate_0.03", "flowrate_0.035", "flowrate_m0.005", "flowrate_m0.01",
"flowrate_m0.015", "flowrate_m0.02", "flowrate_m0.025", "flowrate_m0.03", "flowrate_m0.035",
"flowrate_m0.04"],
changes={})
self.flow_ratios(label, lambda m: (0.98 + m) / 0.98)
label = f"{s} 8"
self.generate(label, {"test": "flow_ratio", "method": "pass1"},
{"method": "pass1", "top_surface_pattern": "archimedeanchords"}, project="Flowrate Test - Pass1",
names=["flowrate_0", "flowrate_10", "flowrate_15", "flowrate_20", "flowrate_5", "flowrate_m10",
"flowrate_m15", "flowrate_m20", "flowrate_m5"],
changes={})
self.flow_ratios(label, lambda m: 1 + m / 100)
label = f"{s} 9"
self.generate(label, {"test": "flow_ratio", "method": "pass2", "top_surface_pattern": "monotonic"},
{"method": "pass2", "top_surface_pattern": "monotonic"}, project="Flowrate Test - Pass2",
names=["flowrate_0"] + [f"flowrate_m{i}" for i in range(1, 10)],
changes={})
self.flow_ratios(label, lambda m: 1 + m / 100, "monotonic")
label = f"{s} 10"
self.generate(label, {"test": "retraction", "end": 1}, {"start": 0, "end": 1, "step": 0.1}, project="Retraction",
names=["retraction_tower.drc"], changes={}, sets={("printer", "use_firmware_retraction"): "0"},
result_keys={"type": "filament", "keys": ["filament_retraction_length"]})
t.equal(f"{label}: the tower's own layer height", self.own(0, "layer_height"), "0.2")
path = self.slice(label, "retraction.gcode")
self.retraction_bands(label, path)
vfa = {"project": "VFA test", "names": ["vfa.drc"], "changes": {"slow_down_layer_time": "0"},
"sets": {("filament", "slow_down_layer_time"): "0", ("process", "spiral_mode"): "1",
("process", "wall_loops"): "1", ("process", "top_shell_layers"): "0",
("process", "bottom_shell_layers"): "1", ("process", "sparse_infill_density"): "0%",
("process", "enable_overhang_speed"): Every("0")},
"result_keys": {"type": "printer", "keys": ["resonance_avoidance", "min_resonance_avoidance_speed",
"max_resonance_avoidance_speed"]}}
label = f"{s} 11"
reply = self.generate(label, {"test": "vfa"},
{"start": 40, "end": 200, "step": 10, "auto_scale": True, "auto_adjust": True}, **vfa)
t.equal(f"{label}: the tower's own layer height", self.own(0, "layer_height"), "0.2")
t.equal(f"{label}: no adjusted", reply.get("adjusted"), None)
self.slice(label)
label = f"{s} 12"
reply = self.generate(label, {"test": "vfa", "end": 400, "step": 20},
{"start": 40, "end": 400, "step": 20, "auto_scale": True, "auto_adjust": True}, **vfa)
lowered = reply.get("adjusted", {}).get("layer_height")
t.check(f"{label}: the layer height is lowered below 0.2", isinstance(lowered, (int, float)) and lowered < 0.2,
reply.get("adjusted"))
own = self.own(0, "layer_height")
t.check(f"{label}: the tower's own layer height is the lowered one",
own is not None and lowered is not None and abs(float(own) - lowered) < 1e-6, (own, lowered))
label = f"{s} 13"
reply = self.generate(label, {"test": "vfa", "end": 400, "auto_adjust": False},
{"start": 40, "end": 400, "step": 10, "auto_scale": True, "auto_adjust": False}, **vfa)
t.equal(f"{label}: no adjusted", reply.get("adjusted"), None)
warnings = reply.get("warnings") or []
t.check(f"{label}: one warning, on the filament's maximum volumetric speed",
len(warnings) == 1
and warnings[0].startswith("the end speed (400 mm/s) exceeds the filament's maximum volumetric speed "
"(21 mm³/s)")
and warnings[0].endswith("(auto_adjust and auto_scale lower the layer height to reach it)"), warnings)
t.equal(f"{label}: the tower's own layer height, half the nozzle", self.own(0, "layer_height"), "0.2")
label = f"{s} 14"
printer = {k: self.value("printer", k).split(",")[0]
for k in ("machine_max_speed_x", "machine_max_speed_y", "machine_max_acceleration_extruding")}
speed = whole(min(float(printer["machine_max_speed_x"]), float(printer["machine_max_speed_y"])))
accel = printer["machine_max_acceleration_extruding"]
shaping = {"changes": {"slow_down_layer_time": "0", "slow_down_min_speed": "0", "slow_down_for_layer_cooling": "0",
"enable_pressure_advance": Every("1"), "pressure_advance": Every("0")},
"sets": {("filament", "slow_down_layer_time"): "0", ("filament", "slow_down_min_speed"): "0",
("filament", "slow_down_for_layer_cooling"): "0",
("filament", "enable_pressure_advance"): Every("1"),
("filament", "pressure_advance"): Every("0"),
("printer", "machine_max_jerk_x"): "10", ("printer", "machine_max_jerk_y"): "10",
("printer", "input_shaping_emit"): "0",
("process", "spiral_mode"): "1", ("process", "wall_loops"): "1",
("process", "top_shell_layers"): "0", ("process", "bottom_shell_layers"): "1",
("process", "sparse_infill_density"): "0%", ("process", "enable_overhang_speed"): Every("0"),
("process", "accel_to_decel_enable"): "1", ("process", "accel_to_decel_factor"): "100%",
("process", "outer_wall_speed"): Every(speed),
("process", "default_acceleration"): Every(accel),
("process", "outer_wall_acceleration"): Every(accel)}}
self.generate(label, {"test": "input_shaping_freq", "start": 20, "end": 80},
{"start": 20, "end": 80, "start_y": 20, "end_y": 80, "damping": 0.15, "shaper_type": "Default",
"test_model": "ringing_tower"},
project="Input shaping Frequency test", names=["ringing_tower.drc"],
result_keys={"type": "printer", "keys": ["input_shaping_emit", "input_shaping_type",
"input_shaping_freq_x", "input_shaping_freq_y",
"input_shaping_damp_x", "input_shaping_damp_y"]},
**shaping)
self.generate(f"{s} 15", {"test": "input_shaping_damp", "freq_x": 48, "freq_y": 42, "test_model": "fast_tower"},
{"freq_x": 48, "freq_y": 42, "start": 0, "end": 0.4, "shaper_type": "Default",
"test_model": "fast_tower"},
project="Input shaping Damping test", names=["fast_tower_test.drc"], **shaping)
label = f"{s} 16"
reply = self.generate(
label, {"test": "cornering", "test_model": "scv_v2", "end": 25}, {"start": 1, "end": 25, "test_model": "scv_v2"},
project="Cornering test", names=["SCV-V2.drc"],
changes={"slow_down_layer_time": "0", "slow_down_min_speed": "0", "slow_down_for_layer_cooling": "0",
"filament_max_volumetric_speed": "200", "enable_pressure_advance": Every("1"),
"pressure_advance": Every("0")},
sets={("printer", "machine_max_jerk_x"): "25", ("printer", "machine_max_jerk_y"): "25",
("printer", "input_shaping_emit"): "1", ("printer", "input_shaping_type"): "Disable",
("filament", "slow_down_layer_time"): "0", ("filament", "slow_down_min_speed"): "0",
("filament", "slow_down_for_layer_cooling"): "0", ("filament", "filament_max_volumetric_speed"): "200",
("filament", "enable_pressure_advance"): Every("1"), ("filament", "pressure_advance"): Every("0")},
result_keys={"type": "printer", "keys": ["machine_max_jerk_x", "machine_max_jerk_y"]})
t.equal(f"{label}: warnings", reply.get("warnings"), ["end 25 is above 20: high values may cause layer shifts"])
self.slice(label)
def flow_ratios(self, label, ratio, pattern=None):
"""Each object's own print_flow_ratio, `ratio` of the number its name ends in, and with `pattern` its own
top_surface_pattern."""
objects = self.objects()
got = [float(self.own(i, "print_flow_ratio")) for i in range(len(objects))]
self.t.near(f"{label}: each object's own flow ratio", got, [ratio(flow_offset(o["name"])) for o in objects],
0.0001)
if pattern is not None:
self.t.equal(f"{label}: each object's own top surface pattern",
[self.own(i, "top_surface_pattern") for i in range(len(objects))], [pattern] * len(objects))
def retraction_bands(self, label, path):
"""The layers cut into bands at each `; Calib_Retraction_tower: ...` line: the bands' lengths in a row, and the
lengths each length's bands restore."""
bands = []
for line in gcode_layers(path):
m = re.match(r"; Calib_Retraction_tower: Z_HEIGHT: [0-9.]+, length:([0-9.]+)", line)
if m:
bands.append((float(m.group(1)), []))
continue
words = line.split(";")[0].split()
if bands and len(words) == 3 and words[0] == "G1" and sorted(w[0] for w in words[1:]) == ["E", "F"]:
e = float(next(w for w in words[1:] if w[0] == "E")[1:])
if e > 0:
bands[-1][1].append(e)
lengths = [round(0.1 * i, 6) for i in range(11)]
self.t.near(f"{label}: the tower's retraction lengths, band by band", in_a_row([b[0] for b in bands]), lengths,
1e-9)
restored = {}
for length, deretractions in bands:
restored.setdefault(round(length, 3), set()).update(round(e, 3) for e in deretractions)
want = {length: {length} for length in lengths}
want[0.0] = {0.8} # the first layer's retraction, made before the tower's first line
self.t.equal(f"{label}: the lengths each band's deretractions restore",
{k: sorted(v) for k, v in restored.items()}, {k: sorted(v) for k, v in want.items()})
def keep_and_discard(self):
s = "keep and discard"
t = self.t
self.run("project_new", **DISCARD)
reply = self.run("action_run", id=FILAMENT_ADD)
t.equal(f"{s} 1: the action's message", reply.get("message"), "Added filament slot 2.")
self.run("settings_set", type="filament", filament_slot=2, values={"filament_cost": 21})
self.run("preset_save", type="filament", name="MCP Calib PLA", filament_slot=2)
self.run("preset_select", type="filament", name=PLA, filament_slot=1)
self.run("settings_set", type="filament", filament_slot=2, values={"filament_cost": 22})
after1 = S("X1C | Std | PLA, MCP Calib PLA[filament_cost 22]")
self.selection_is(f"{s} 1", after1)
saved_cost = lambda: self.value("filament", "filament_cost", preset="MCP Calib PLA") # noqa: E731
t.equal(f"{s} 1: the saved cost", saved_cost(), "21")
self.refused(f"{s} 2: keep is refused while the tab edits another slot's modified preset",
lambda: self.c.call("calibration_generate_test", test="retraction", discard_changes=True,
preset_changes="keep"),
words='The filament tab edits "MCP Calib PLA", which has unsaved changes, and the test prints '
'with filament slot 1 ("Bambu PLA Basic @BBL X1C")')
self.selection_is(f"{s} 2", after1)
t.equal(f"{s} 2: no objects", self.objects(), [])
t.equal(f"{s} 2: the saved cost", saved_cost(), "21")
reply = self.run("calibration_generate_test", test="retraction", **DISCARD)
filament = reply.get("presets_changed", {}).get("filament", {})
t.equal(f"{s} 3: the filament tab switched to slot 1",
{k: filament.get(k) for k in ("name", "tab_switched_from")},
{"name": PLA, "tab_switched_from": "MCP Calib PLA"})
t.equal(f"{s} 3: discarded", reply.get("discarded", {}).get("filament"),
{"name": "MCP Calib PLA", "keys": ["filament_cost"]})
t.equal(f"{s} 3: the reply's names", reply.get("names"), ["retraction_tower.drc"])
t.equal(f"{s} 3: the objects", [o["name"] for o in self.objects()], ["retraction_tower.drc"])
self.selection_is(f"{s} 3", S("X1C | Std | PLA, MCP Calib PLA"))
t.equal(f"{s} 3: slot 2's cost", self.value("filament", "filament_cost", slot=2), "21")
self.run("settings_set", type="filament", values={"slow_down_layer_time": 7})
reply = self.run("calibration_generate_test", test="retraction", discard_changes=True, preset_changes="keep")
t.equal(f"{s} 4: modified", reply.get("modified", {}).get("filament", {}).get("keys"), ["slow_down_layer_time"])
t.equal(f"{s} 4: nothing discarded", reply.get("discarded"), None)
self.selection_is(f"{s} 4", S("X1C | Std | PLA[slow_down_layer_time 7], MCP Calib PLA"))
reply = self.run("project_new", **DISCARD)
t.check(f"{s} 5: discarded holds slow_down_layer_time",
"slow_down_layer_time" in reply.get("discarded", {}).get("filament", {}).get("keys", []), reply)
t.equal(f"{s} 5: nothing modified", reply.get("modified"), None)
self.selection_is(f"{s} 5", S("X1C | Std | PLA, MCP Calib PLA"))
t.equal(f"{s} 5: slow_down_layer_time", self.value("filament", "slow_down_layer_time"), "4")
reply = self.run("filament_delete", filament_slot=2)
t.equal(f"{s} 6: the slot's delete", reply.get("level"), "success")
reply = self.run("preset_delete", type="filament", name="MCP Calib PLA")
t.equal(f"{s} 6: the preset's delete", reply.get("deleted"), "MCP Calib PLA")
self.selection_is(f"{s} 6", S("X1C | Std | PLA"))
listed = self.c.call("preset_list", type="filament", limit=500)["items"]
t.equal(f"{s} 6: the filaments listed", [(i["name"], i.get("modified")) for i in listed], [(PLA, None)])
def run_all(self):
for name, scenario in [("the temperature tower, and what is refused", self.temperature),
("the other tests", self.other_tests), ("keep and discard", self.keep_and_discard)]:
self.t.scenario(name, scenario)
self.run("project_new", **DISCARD)
return self.t.exit_code()
def main():
client, _ = orca_mcp.session_client()
with tempfile.TemporaryDirectory(prefix="orca-calibration-") as folder:
return CalibrationTest(client, folder).run_all()
if __name__ == "__main__":
sys.exit(main())
+338
View File
@@ -0,0 +1,338 @@
#!/usr/bin/env python3
"""The forms a call takes, as the test_call_forms entry of tools/mcp/test-entries/gui_tools.md designs them.
tools/mcp/orca_mcp.py launch --cad
tools/mcp/test_call_forms.py [--out DIR]
Names and value shapes agents send in place of the schema's, each shown by what the call did; settings_list leaving
meta out of a whole listing; and a call with exactly an action's arguments doing what a person's pick does: a test's
dialog asked or silent, View: Top turning the camera of the view shown, Deselect All closing the open gizmo too, Go to
layer through action_run, and plate_slice {preview: true}. It needs the Design tab (launch with --cad), runs on the
harness's default printer, the Bambu Lab X1 Carbon 0.4, and exits 0 when every check passes. The files it exports
go to --out, else to a new temporary folder.
"""
import argparse
import os
import struct
import sys
import tempfile
import threading
import time
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import orca_mcp # noqa: E402
from checks import Checks, plates, run, wait # noqa: E402
REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
CUBE = os.path.join(REPO, "resources", "handy_models", "OrcaCube_v2.drc")
NAME = "OrcaCube_v2.drc"
PREFERENCES = "orca_command:open_preferences:orca"
def stl(path):
"""A binary STL's triangle count and its size in bytes."""
with open(path, "rb") as f:
head = f.read(84)
return struct.unpack("<I", head[80:84])[0], os.path.getsize(path)
class CallFormsTest:
def __init__(self, client, session, folder):
self.c = client
self.session = session
self.t = Checks()
self.folder = folder
# ---- Calls and reads ----
def run(self, tool, **args):
return run(self.c, tool, **args)
def state(self):
return self.c.call("app_state")
def objects(self):
"""Each object as {name, plate, offset, bbox}, offset and bbox being its first instance's."""
listing = self.c.call("object_list", limit=500)
return [{"name": o["name"], "plate": p["index"], "offset": o["instances"][0]["offset"],
"bbox": o["instances"][0]["bbox"]} for p in listing["plates"] for o in p["objects"]]
def names(self):
return [o["name"] for o in self.objects()]
def selection(self):
sel = self.state().get("selection") or {}
return {"objects": sel.get("objects", []), "parts": sel.get("parts", [])}
def selected(self, label, *objects):
self.t.equal(f"{label}: the selection", self.selection(), {"objects": list(objects), "parts": []})
def camera(self):
cam = self.state()["camera"]
return {k: cam.get(k) for k in ("elevation", "azimuth", "look_at", "zoom")}
def legend(self):
return self.c.call("plate_slice_stats", include=["view"])["view"]["legend"]
def modified(self):
out = []
for kind in ("printer", "process", "filament"):
out += [p["name"] for p in self.c.call("preset_list", type=kind, limit=500)["items"] if p.get("modified")]
return out
def dialogs(self):
return [d.get("title") for d in self.state().get("dialogs", [])]
def job_ends(self, label, job):
try:
self.c.await_job(job, timeout=60)
self.t.check(f"{label}: the job ends without an error", True)
except orca_mcp.McpError as e:
self.t.check(f"{label}: the job ends without an error", False, str(e))
def start(self, name):
self.run("project_new", discard_changes=True, preset_changes="discard")
self.run("view_set", tab="prepare")
self.run("dialog_auto_answer", rules=[{"match": "restore", "button": "no"}])
wait(self.c, "idle")
self.t.equal(f"{name}: the start: the objects", self.objects(), [])
self.t.equal(f"{name}: the start: the dialogs open", self.dialogs(), [])
self.t.equal(f"{name}: the start: the plates", plates(self.c),
[{"name": "", "current": True, "locked": False, "objects": 0}])
# ---- Scenarios ----
def agent_names(self):
s = "names and values agents send"
self.start(s)
reply = self.run("project_import", paths=CUBE)
self.t.equal(f"{s} 1: a lone path: the reply's added", reply.get("added"), 1)
self.t.equal(f"{s} 1: the names", self.names(), [NAME])
self.run("project_import", paths=[CUBE])
self.t.equal(f"{s} 2: the names", self.names(), [NAME, NAME])
self.run("object_select", objects=[0])
self.selected(f"{s} 3", 0)
self.run("object_select", object="1")
self.selected(f"{s} 4: object and a string index", 1)
reply = self.run("object_rename", name="renamed")
self.t.equal(f"{s} 5: the reply", reply.get("ran"), "object_rename")
self.t.equal(f"{s} 5: the selected object was renamed", self.names(), [NAME, "renamed"])
reply = self.run("action_run", action="view_top")
self.t.equal(f"{s} 6: action and the short name", reply.get("ran"), "orca_command:view_top:orca")
self.t.near(f"{s} 6: the camera looks down", self.camera()["elevation"], 90, 0.1)
reply = self.run("view_set", canvas="front")
self.t.equal(f"{s} 7: canvas for camera", reply.get("camera"), "front")
cam = self.camera()
self.t.near(f"{s} 7: the camera's elevation and azimuth", [cam["elevation"], cam["azimuth"]], [0, -90], 0.1)
for i in (0, 1):
self.run("object_transform", object=i, position=[100, 110, 0])
for o in self.objects():
self.t.near(f"{s} 8: position: {o['name']} at x 100, y 110", o["offset"][:2], [100, 110], 0.01)
self.run("object_select", objects=[0])
self.selected(f"{s} 9: after the select", 0)
self.run("keyboard_press", key="Escape", target={"name": "OrcaSceneCanvas"})
self.selected(f"{s} 9: key for keys: Escape reached the 3D view")
job = self.c.call("action_run", id=PREFERENCES)
self.t.equal(f"{s} 10: the action waits on its dialog", job.get("status"), "blocked_by_dialog")
self.t.equal(f"{s} 10: the dialogs open", self.dialogs(), ["Preferences"])
self.wait_without_condition(s)
self.run("object_select", objects=[0])
self.selected(f"{s} 12: after the select", 0)
reply = self.run("widget_click", target={"gizmo": "Support Painting"})
self.t.equal(f"{s} 12: a gizmo by its toolbar title",
(reply.get("gizmo"), reply.get("active")), ("FdmSupports", True))
self.t.equal(f"{s} 12: the gizmo open", (self.state().get("gizmo") or {}).get("name"), "FdmSupports")
reply = self.run("widget_click", target={"gizmo": "support painting"})
self.t.equal(f"{s} 13: the title in another case closes it", reply.get("active"), False)
self.t.equal(f"{s} 13: no gizmo open", self.state().get("gizmo"), None)
self.run("object_arrange", plate="0")
wait(self.c, "idle")
self.apart_on_plate_0(f"{s} 14: plate as a string")
reply = self.run("plate_slice", plate="0")
self.t.equal(f"{s} 15: plate as a string: the slice",
[(p.get("index"), p.get("outcome")) for p in reply.get("plates", [])], [(0, "ok")])
self.t.equal(f"{s} 15: plate 0 is sliced", self.c.call("plate_list")["items"][0]["sliced"], True)
reply = self.run("view_set", tab="preview",
legend={"sparse_infill": False, "Travel": False, "Prime tower": False, "Pauses": False})
self.t.equal(f"{s} 16: legend rows in another case or with _", reply.get("legend"),
{"Sparse infill": False, "travel": False})
legend = self.legend()
self.t.equal(f"{s} 16: the rows hidden", (legend["features"].get("Sparse infill"), legend["options"].get("travel")),
(False, False))
self.run("view_set", legend={"Sparse infill": True, "travel": True})
legend = self.legend()
self.t.equal(f"{s} 17: the rows shown", (legend["features"].get("Sparse infill"), legend["options"].get("travel")),
(True, True))
self.run("view_set", tab="prepare")
self.t.equal(f"{s} 18: the tab", self.state()["tab"], "prepare")
gcode = os.path.join(self.folder, "forms.gcode")
reply = self.run("project_export", path=gcode, overwrite=True)
self.t.equal(f"{s} 18: the export", reply.get("export"), "ok")
with open(gcode, encoding="utf-8", errors="replace") as f:
first = f.readline().rstrip("\r\n")
self.t.equal(f"{s} 18: the format came from the path: G-code", first, "; HEADER_BLOCK_START")
path = os.path.join(self.folder, "forms.stl")
reply = self.run("project_export", path=path, overwrite=True)
self.t.equal(f"{s} 19: the objects written", [o.get("index") for o in reply.get("objects", [])], [0, 1])
self.t.equal(f"{s} 19: the reply's bytes are the file's", reply.get("bytes"), os.path.getsize(path))
triangles = sum(part["triangles"] for p in self.c.call("object_list")["plates"] for o in p["objects"]
for part in o["parts"])
count, size = stl(path)
self.t.equal(f"{s} 19: the STL holds the objects' triangles", count, triangles)
self.t.equal(f"{s} 19: the STL's size", size, 84 + 50 * count)
items = self.c.call("settings_list", type="process", limit=5)["items"]
self.t.equal(f"{s} 20: five settings", len(items), 5)
self.t.check(f"{s} 20: each with a value and no meta", all("value" in i and "meta" not in i for i in items), items)
items = self.c.call("settings_get", type="process", keys=["wall_loops"])["items"]
self.t.equal(f"{s} 21: settings_get gives the meta", items[0].get("meta", {}).get("type"), "int")
def wait_without_condition(self, s):
"""Step 11: a second client's app_wait {} while Preferences is open, seen unfinished in replay_export."""
other = orca_mcp.OrcaMcp(self.session["port"], self.session["token"])
done = {}
def wait_idle():
try:
started = time.monotonic()
done["reply"] = other.call("app_wait", _timeout=120)
done["seconds"] = time.monotonic() - started
except Exception as e: # reported by the checks below
done["error"] = e
thread = threading.Thread(target=wait_idle, daemon=True)
thread.start()
running = lambda: self.c.call("replay_export").get("left_out_running")
deadline = time.monotonic() + 10
while running() != [{"tool": "app_wait"}] and time.monotonic() < deadline:
time.sleep(0.1)
seen = running()
self.t.equal(f"{s} 11: replay_export lists the wait unfinished", seen, [{"tool": "app_wait"}])
time.sleep(1)
self.t.equal(f"{s} 11: a second later the wait is still unfinished", running(), [{"tool": "app_wait"}])
self.t.equal(f"{s} 11: Preferences is still open", self.dialogs(), ["Preferences"])
self.c.call("dialog_answer", dialog={"title": "Preferences"}, button="close")
thread.join(60)
reply = done.get("reply") or {}
self.t.check(f"{s} 11: the wait ends without an error", "error" not in done and not thread.is_alive(), done)
self.t.equal(f"{s} 11: the wait is satisfied", reply.get("satisfied"), True)
self.t.check(f"{s} 11: the wait lasted at least a second", reply.get("waited_ms", 0) >= 1000, reply)
self.t.check(f"{s} 11: replay_export lists nothing unfinished", "left_out_running" not in self.c.call("replay_export"),
self.c.call("replay_export").get("left_out_running"))
self.t.equal(f"{s} 11: no dialog", self.dialogs(), [])
def apart_on_plate_0(self, label):
objects = self.objects()
self.t.equal(f"{label}: both objects on plate 0", [o["plate"] for o in objects], [0, 0])
item = self.c.call("plate_list")["items"][0]
(x, y), (w, d) = item["origin"], item["size"]
for o in objects:
box = o["bbox"]
inside = box["min"][0] >= x and box["min"][1] >= y and box["max"][0] <= x + w and box["max"][1] <= y + d
self.t.check(f"{label}: {o['name']} lies inside plate 0", inside, (box, (x, y, w, d)))
a, b = (o["bbox"] for o in objects)
apart = (a["max"][0] <= b["min"][0] or b["max"][0] <= a["min"][0] or a["max"][1] <= b["min"][1] or
b["max"][1] <= a["min"][1])
self.t.check(f"{label}: the objects' footprints are apart", apart, (a, b))
def test_dialog(self):
s = "a test's dialog, asked or silent"
self.start(s)
project = self.state()["project"]
self.t.equal(f"{s}: the start: the project's name", project.get("name"), "Untitled")
self.t.equal(f"{s}: the start: no preset modified", self.modified(), [])
job = self.c.call("calibration_generate_test", test="temperature")
self.t.equal(f"{s} 1: the test asks in its dialog", job.get("status"), "blocked_by_dialog")
self.t.equal(f"{s} 1: the dialogs open", self.dialogs(), ["Temperature calibration"])
self.c.call("dialog_answer", dialog={"title": "Temperature calibration"}, button="cancel")
self.job_ends(f"{s} 2: the step 1 call", job)
wait(self.c, "idle")
self.t.equal(f"{s} 2: the dialogs open", self.dialogs(), [])
self.t.equal(f"{s} 2: Cancel adds no object", self.objects(), [])
project = self.state()["project"]
self.t.equal(f"{s} 2: the project is as it was", (project.get("name"), project.get("dirty")), ("Untitled", False))
self.t.equal(f"{s} 2: no preset modified", self.modified(), [])
reply = self.run("calibration_generate_test", test="temperature", silent=True, discard_changes=True,
preset_changes="discard")
wait(self.c, "idle")
self.t.equal(f"{s} 3: the reply", (reply.get("test"), reply.get("names")), ("temperature", ["temperature_tower.drc"]))
self.t.equal(f"{s} 3: the names", self.names(), ["temperature_tower.drc"])
self.t.equal(f"{s} 3: the project's name", self.state()["project"].get("name"), "Nozzle temperature test")
self.t.equal(f"{s} 3: silent asks nothing", self.dialogs(), [])
def shown_view(self):
s = "the shown view"
self.start(s)
self.run("project_import", paths=[CUBE])
self.run("object_transform", object=0, size=[20, 20, 20])
objects = self.objects()
self.t.equal(f"{s}: the start: one object on plate 0", [o["plate"] for o in objects], [0])
self.t.near(f"{s}: the start: 20 mm", objects[0]["bbox"]["size"] if objects else None, [20, 20, 20], 0.01)
self.run("view_set", tab="prepare", camera="front")
self.t.equal(f"{s} 1: the tab", self.state()["tab"], "prepare")
self.t.near(f"{s} 1: the Prepare view's elevation", self.camera()["elevation"], 0, 0.1)
reply = self.run("view_set", tab="design", camera="front")
self.t.near(f"{s} 2: the reply's elevation", (reply.get("camera_state") or {}).get("elevation"), 0, 0.1)
self.t.equal(f"{s} 2: the tab", self.state()["tab"], "design")
self.t.near(f"{s} 2: the Design tab's elevation", self.camera()["elevation"], 0, 0.1)
reply = self.run("action_run", id="view_top")
self.t.equal(f"{s} 3: the action run", reply.get("ran"), "orca_command:view_top:orca")
self.t.near(f"{s} 3: the reply's elevation", (reply.get("camera_state") or {}).get("elevation"), 90, 0.1)
self.t.equal(f"{s} 3: the tab", self.state()["tab"], "design")
self.t.near(f"{s} 3: the Design tab's elevation", self.camera()["elevation"], 90, 0.1)
self.run("view_set", tab="prepare")
self.t.equal(f"{s} 4: the tab", self.state()["tab"], "prepare")
self.t.near(f"{s} 4: View: Top left the Prepare view's camera", self.camera()["elevation"], 0, 0.1)
self.run("object_select", objects=[0])
self.run("widget_click", target={"gizmo": "Support Painting"})
self.selected(f"{s} 5", 0)
self.t.equal(f"{s} 5: the gizmo open", (self.state().get("gizmo") or {}).get("name"), "FdmSupports")
reply = self.run("action_run", id="deselect_all")
self.t.equal(f"{s} 6: the reply", (reply.get("ran"), reply.get("empty"), reply.get("canvas")),
("orca_command:deselect_all:orca", True, "3d"))
self.selected(f"{s} 6")
self.t.equal(f"{s} 6: Deselect All closes the open gizmo too", self.state().get("gizmo"), None)
reply = self.run("plate_slice", preview=True)
self.t.equal(f"{s} 7: the slice", (reply.get("status"), [p.get("outcome") for p in reply.get("plates", [])]),
("done", ["ok"]))
self.t.equal(f"{s} 7: the tab", self.state()["tab"], "preview")
self.t.equal(f"{s} 7: plate 0 is sliced", self.c.call("plate_list")["items"][0]["sliced"], True)
self.run("action_run", id="go_to_layer", args={"percent": 50})
view = self.c.call("plate_slice_stats", include=["view"])["view"]
self.t.equal(f"{s} 8: the layers", view.get("layer_count"), 100)
self.t.equal(f"{s} 8: the range shown", view.get("layers"), [1, 51])
def run_all(self):
for name, scenario in [("names and values agents send", self.agent_names),
("a test's dialog, asked or silent", self.test_dialog),
("the shown view", self.shown_view)]:
self.t.scenario(name, scenario)
self.c.call("dialog_auto_answer", rules=[])
self.run("project_new", discard_changes=True, preset_changes="discard")
return self.t.exit_code()
def main():
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("--out", help="folder for the exported files (default: a new temporary folder)")
args = ap.parse_args()
folder = args.out or tempfile.mkdtemp(prefix="orca-call-forms-")
os.makedirs(folder, exist_ok=True)
print(f"output folder: {folder}", flush=True)
client, session = orca_mcp.session_client()
return CallFormsTest(client, session, folder).run_all()
if __name__ == "__main__":
sys.exit(main())
+53 -10
View File
@@ -6,7 +6,10 @@
A slice requested right after a setting change first waits for the update the change scheduled
(half a second), and only then starts. A cancel sent during that wait must keep it from starting:
the slice reports its plate cancelled. Exits 0 when it does.
the slice reports its plate cancelled, the Prepare tab stays shown (a slice that starts shows the
Preview), and the plate stays unsliced, so its G-code export is refused as plate_not_sliced. A slice
made afterwards is the control: it shows the Preview, slices the plate and exports. Exits 0 when
every check passes.
"""
import os
@@ -17,16 +20,32 @@ import time
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import orca_mcp # noqa: E402
from checks import refusal # noqa: E402
MODEL = os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", "..", "resources", "handy_models", "3DBenchy.drc")
def main():
client, _ = orca_mcp.session_client()
gcode = os.path.join(tempfile.mkdtemp(prefix="orca-mcp-"), "plate.gcode")
checks = []
def check(name, ok, detail):
checks.append((name, ok, detail))
def tab():
return client.call("app_state").get("tab")
def sliced():
return client.call("plate_list")["items"][0]["sliced"]
client.call("dialog_auto_answer", rules=[{"match": "unsaved changes", "button": "no"}])
client.call("project_new", discard_changes=True)
client.call("project_import", paths=[os.path.abspath(MODEL)])
client.call("view_set", tab="prepare")
client.call("app_wait", **{"for": "idle"})
start = (tab(), sliced())
check("the slice starts from Prepare, unsliced", start == ("prepare", False), start)
client.call("settings_set", type="process", values={"sparse_infill_density": "35%"})
box = {}
@@ -36,21 +55,45 @@ def main():
cancel = client.call("job_cancel")
worker.join(600)
result = client.await_job(box["result"])
check("job_cancel reports the waiting slice", cancel.get("was_running") is True, cancel)
check("the slice reports its plate cancelled",
result.get("status") == "done" and result.get("plates") == [{"index": 0, "outcome": "cancelled"}], result)
shown = tab()
check("the cancel came before the slice started", shown == "prepare", f"the {shown} tab is shown")
client.call("dialog_auto_answer", rules=[])
# Once the scheduled update has run, the plate must still have no result to export.
client.call("app_wait", **{"for": "idle"})
problems = []
if sliced() is not False:
problems.append("plate_list gives plate 0 sliced")
try:
client.call("project_export", format="gcode", path=os.path.join(tempfile.mkdtemp(prefix="orca-mcp-"), "plate.gcode"))
unsliced = False
except orca_mcp.McpError:
unsliced = True
reply = client.call("project_export", format="gcode", path=gcode)
problems.append(f"the G-code export went through: {reply}")
except orca_mcp.McpError as e:
text, details = refusal(e)
if details.get("code") != "plate_not_sliced":
problems.append(f"the G-code export was refused as {details.get('code')!r}: {text}")
if os.path.exists(gcode):
problems.append("the refused export wrote its file")
check("the plate stays unsliced", not problems, "; ".join(problems))
# The control: a slice that starts shows the Preview and leaves a plate that exports.
problems = []
control = client.await_job(client.call("plate_slice", _timeout=600))
if [p.get("outcome") for p in control.get("plates", [])] != ["ok"]:
problems.append(f"the slice replied {control}")
if (shown := tab()) != "preview":
problems.append(f"the {shown} tab is shown")
if sliced() is not True:
problems.append("plate_list gives plate 0 unsliced")
client.call("project_export", format="gcode", path=gcode)
if not (os.path.isfile(gcode) and os.path.getsize(gcode) > 0):
problems.append("the export wrote no G-code")
check("a slice afterwards runs and exports", not problems, "; ".join(problems))
failures = 0
for name, ok, detail in [
("job_cancel reports the waiting slice", cancel.get("was_running") is True, cancel),
("the slice reports its plate cancelled", result["plates"][0]["outcome"] == "cancelled", result),
("the plate stays unsliced", unsliced, "a G-code export succeeded"),
]:
for name, ok, detail in checks:
print(("ok " if ok else "FAIL ") + name + ("" if ok else f": {detail}"))
failures += not ok
return 1 if failures else 0
+35 -14
View File
@@ -27,11 +27,14 @@ child processes.
folder that is neither the data folder, the resources folder nor the script's own, exits 0, and the conf's
python_scripts_unrestricted is absent or false after exit; without the flag the same run exits 1.
- cad_flag: --cad --mcp on a fresh data folder: tool_search {group: Design} finds commands and app_state has no
cad_note; after exit the conf's enable_cad_feature is absent or false. A second start without the flag on the same
folder finds no Design command.
cad_note; File > Quit ends it with exit code 0, and only then, since the app writes its conf as it exits, is the
conf's enable_cad_feature read: absent or false. A second start without the flag on the same folder finds no
Design command.
- run_beside_open_window: with single_instance true in the conf and a first window serving on the same data folder,
--run r.json runs in a second process, exits 0 and writes its result.json, and the first window has loaded no
object; then, with that window closed, two --run r.json processes started together on that folder both exit 0.
--run r.json, a replay whose one step is app_state expecting mcp.serving false, runs in a second process, exits 0
and writes a result.json that says passed: a run that went into the serving first window would fail its expect,
and one that handed its command line over would exit -1. Then, with that window closed, two --run r.json processes
started together on that folder both exit 0 and write their result.json.
- window_per_data_folder: with single_instance true in both confs and a first window serving on one data folder, a
start on that folder with a model exits -1, having handed its command line over, and the first window loads the
model (on Linux, which hands it over on the session bus a headless run may lack, only the exit code is checked);
@@ -69,6 +72,10 @@ MODEL = os.path.join(HERE, "..", "..", "resources", "handy_models", "OrcaCube_v2
DROPPED = (McpError, OSError, http.client.HTTPException)
REPLAY = {"orca_replay_version": "0.2.0", "name": "the app's state", "steps": [{"tool": "app_state"}]}
# A --run without --mcp opens no endpoint, so this replay passes only in a process of its own, never in a window
# that serves.
OFF_SERVER_REPLAY = {"orca_replay_version": "0.2.0", "name": "the app's state without the server",
"steps": [{"tool": "app_state", "expect": {"/mcp/serving": {"eq": False}}}]}
SCREENSHOT_SCRIPT = """
import orca
orca.host.tools.call("window_screenshot", {"include_image": False})
@@ -113,6 +120,15 @@ def is_off(value):
return value in (None, False, "false", "0")
def result_passed(folder):
"""The `passed` of the result.json in `folder`, or why it could not be read."""
try:
with open(os.path.join(folder, "result.json"), encoding="utf-8") as f:
return json.load(f).get("passed")
except (OSError, ValueError) as e:
return f"unreadable ({e})"
class Work:
"""A check's temporary folder, short enough for the first start's profile copy: the data folder is its `data`
subfolder, launched from with no .py file in it, and the check's files go in `files`."""
@@ -413,10 +429,15 @@ def cad_flag(binary):
note = app.orca.call("app_state").get("cad_note")
if note is not None:
problems.append(f"--cad --mcp: app_state has cad_note {note!r}")
app.quit()
value = read_conf(work.datadir).get("enable_cad_feature")
if not is_off(value):
problems.append(f"the conf's enable_cad_feature is {value!r} after exit")
# The app writes its conf as it exits, so the conf tells what the run kept only after a clean exit.
code = app.quit()
if code != 0:
problems.append(f"--cad --mcp: File > Quit ended with {'a kill' if code is None else f'exit code {code}'}, "
"so the conf was not read")
else:
value = read_conf(work.datadir).get("enable_cad_feature")
if not is_off(value):
problems.append(f"the conf's enable_cad_feature is {value!r} after exit")
app = work.start(binary, "--mcp", name="no-flag")
if (why := app.serve(PORT)):
problems.append(f"--mcp: {why}")
@@ -427,13 +448,14 @@ def cad_flag(binary):
elif count != 0:
problems.append(f"--mcp without --cad: tool_search finds {count} Design commands")
app.quit()
check("cad_flag", problems, f"{found} Design commands with --cad, none without, enable_cad_feature stayed off")
check("cad_flag", problems, f"{found} Design commands with --cad, none without, File > Quit exited 0 and "
"enable_cad_feature stayed off")
def run_beside_open_window(binary):
problems = []
with Work(single_instance=True) as work:
replay = work.file("r.json", json.dumps(REPLAY))
replay = work.file("r.json", json.dumps(OFF_SERVER_REPLAY))
first = work.start(binary, "--mcp", "--mcp-port", str(PORT), name="first")
if (why := first.serve(PORT)):
return check("run_beside_open_window", [f"the first window: {why}"], "")
@@ -443,9 +465,8 @@ def run_beside_open_window(binary):
problems.append(f"--run r.json beside the first window: exit code {code}")
if not os.path.isfile(os.path.join(out, "result.json")):
problems.append("--run r.json beside the first window: no result.json")
objects = first.orca.call("app_state").get("objects")
if objects != 0:
problems.append(f"the first window has {objects} objects")
elif (passed := result_passed(out)) is not True:
problems.append(f"--run r.json beside the first window: result.json's passed is {passed}")
first.quit()
both = [(os.path.join(work.root, f"together{i}"), work.start(binary, "--run", replay, "--outputdir",
os.path.join(work.root, f"together{i}"),
@@ -457,7 +478,7 @@ def run_beside_open_window(binary):
if not os.path.isfile(os.path.join(folder, "result.json")):
problems.append(f"run {i} of two started together: no result.json")
check("run_beside_open_window", problems,
"the run beside an open window exited 0 there and loaded nothing into it; two together both exited 0")
"the run beside an open window exited 0 and passed in a process of its own; two together both exited 0")
def short_path(path):
+12 -7
View File
@@ -13,9 +13,12 @@ dialogs, a text typed into it first, or a rule for a native file picker register
output folder.
For every action that ran, the reply's ran is the action's id, and the step replay_export writes for the call is an
action_run of that id with the arguments of tests/data/speed_dial_action_calls.json (for Go to tab and Go to layer the
value under the action's input token), the action naming the fixture's command in action_search. An action expected to
be refused has neither: action_run adds ran only when the command ran, and a failed call is not exported.
action_run of that id with the arguments its command journals: for Go to tab and Go to layer the value under the
action's input token, and none for every other action, whose command journals nothing of its own (a step with the id
alone replays the same, since the action supplies its fixed arguments). The calibration actions are among those: they
open their test's dialog, and calibration_generate_test journals its arguments only when it runs the test itself. The
action names the command of tests/data/speed_dial_action_calls.json in action_search. An action expected to be refused
has neither: action_run adds ran only when the command ran, and a failed call is not exported.
Three actions open a web page in the system's browser and one opens the configuration folder in the file manager; the
test runs them once and leaves what they opened. Send G-code, Synchronize Filament List from AMS and Sync Presets are
@@ -605,7 +608,9 @@ ROWS = dict([
row("open_youtube", "empty", external("it opens the YouTube channel in the system's browser")),
# ---- Plugins ----
row("open_plugins", "empty", window("Plugins"), post=[call("keyboard_press", keys="Escape", target={"label": "Plugins"})]),
row("refresh_plugins", "empty", ("plugin_list", lambda r: (SIDE_LOADED in r.plugin_names(), r.plugin_names())),
# The side-loaded plugin is listed only once the refresh has found it.
row("refresh_plugins", "empty", ("plugin_list", lambda r: (r.before is False and SIDE_LOADED in r.plugin_names(),
(r.before, r.plugin_names()))),
before=lambda r: side_load(r)),
row("install_plugin", "empty", external("it opens the plugin hub in the system's browser")),
row("install_local_plugin", "empty", ("plugin_list", lambda r: (LOCAL_PLUGIN in r.plugin_names(), r.plugin_names())),
@@ -736,9 +741,9 @@ def main():
step = journal_step(run, key)
spec = fixture.get(key, {})
given = step.get("args", {}).get("args", {}) if step else None
wanted = ({spec["input"]: list(r["value"].values())[0]} if spec.get("input") else spec.get("args"))
check(f"{name}: the journal keeps its action_run with the fixture's arguments",
step is not None and given in ({}, wanted) and (given == wanted or not spec.get("input")), step)
wanted = {spec["input"]: list(r["value"].values())[0]} if spec.get("input") else {}
check(f"{name}: the journal keeps its action_run with the arguments its command journals",
step is not None and given == wanted, (step, wanted))
check(f"{name}: its action names the fixture's command", commands.get(action_id(key)) == spec.get("command"),
(commands.get(action_id(key)), spec.get("command")))
if r["why"]:
+910
View File
@@ -0,0 +1,910 @@
#!/usr/bin/env python3
"""The filament slots and what the project does with them, as the test_filaments entry of
tools/mcp/test-entries/filaments_settings.md designs them.
tools/mcp/orca_mcp.py launch
tools/mcp/test_filaments.py
Assigning a filament preset to a slot by each route a person or a plugin has (a pick in the slot's selector, the
selector's value set, preset_select and the plugin API), with one slot, where the filament tab switches and its
unsaved-changes prompt applies, and with three, where the Auto-flush preference decides what happens to the flushing
volumes; then the filaments of objects and parts, and the project's own settings with what reaches the print and what
the project file keeps. After every step the test reads the state back through other tools and compares it with the
state the entry writes out. It needs a fresh app and data folder, whose selectors have not shown the presets it
picks, on the harness's default printer, the Bambu Lab X1 Carbon 0.4, and exits 0 when every check passes.
"""
import os
import sys
import tempfile
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import orca_mcp # noqa: E402
from checks import Checks, run, wait # noqa: E402
B = "Bambu PLA Basic @BBL X1C"
X = "FilAr PLA Blanco Calido"
M = "Bambu PLA Matte @BBL X1C"
S = "Bambu Support For PLA @BBL X1C"
A = "Bambu Support for ABS @BBL X1C"
G = "Bambu PETG Basic @BBL X1C"
H = "Bambu PETG HF @BBL X1C"
LETTER = {B: "B", X: "X", M: "M", S: "S", A: "A", G: "G", H: "H"}
# The name each preset's selector shows, which a pick clicks.
SHOWN = {B: "Bambu PLA Basic", X: "FilAr PLA Blanco Calido", M: "Bambu PLA Matte", S: "Bambu Support For PLA",
A: "Bambu Support for ABS", G: "Bambu PETG Basic", H: "Bambu PETG HF"}
GREYS = ["#111111", "#222222", "#333333"]
SENTINEL = 777
PROMPT = "Transfer or discard changes"
FLUSH = {"All": "all", "Color": "color change", "None": "disabled"}
# The states' short forms, as the entry writes them.
COLOURS = {"#111111;#222222;#333333": "c3", "#111111;#FFF8E7;#333333": "cX"}
MATRICES = {"0,777,777,777,0,777,777,777,0": "S3", "0,230,777,700,0,700,777,230,0": "Sup"}
CUBE = {"shape": "cube", "size": [20, 20, 10], "name": "cube", "position": [100, 100, 0]}
CYLINDER = {"shape": "cylinder", "size": [20, 10], "name": "cylinder", "position": [160, 100, 0]}
PART_NOTE = 'A part\'s value (source "part", or in parts) applies only inside that part\'s volume.'
# The plugin API call a row makes, run with script_run: `body` sets `result`, and an exception the API raises is
# returned as {raised: {type, message}}.
API = """
import orca
f = orca.host.preset.filament
def tx(t):
return {"target_name": t.target_name, "selection_changed": t.selection_changed, "slot_number": t.slot_number}
def done(r):
return {"target_name": r.target_name, "selection_changed": r.selection_changed,
"slot_assignment_changed": r.slot_assignment_changed, "shared_slots": list(r.shared_slots),
"keys": list(r.keys), "dirty": r.dirty}
try:
%s
except Exception as e:
result = {"raised": {"type": type(e).__name__, "message": str(e)}}
"""
def args_of(*args):
return ", ".join(repr(a) for a in args)
def commit_form(*args):
"""begin_update(*args).commit()"""
return f" result = done(f.begin_update({args_of(*args)}).commit())"
def begin_form(*args):
"""begin_update(*args), not committed"""
return f" result = tx(f.begin_update({args_of(*args)}))"
def update_form(*args):
"""update(*args), which returns nothing"""
return f" f.update({args_of(*args)})\n result = 'returned'"
def set_commit_form(slot, key, value):
"""t = begin_update(slot); t.set(key, value); t.commit()"""
return f" t = f.begin_update({slot!r})\n t.set({key!r}, {value!r})\n result = done(t.commit())"
def commit(name, selection=True, assignment=True, shared=(1,), keys=(), dirty=False):
return {"target_name": name, "selection_changed": selection, "slot_assignment_changed": assignment,
"shared_slots": list(shared), "keys": list(keys), "dirty": dirty}
def raised(kind, message):
return {"raised": {"type": kind, "message": message}}
def canceled(name, slot):
return raised("RuntimeError", f'Switching the edited filament preset to "{name}" for filament slot {slot} was '
f"canceled; neither the slot assignment nor any setting was changed")
def numbers(text):
return [float(v) for v in text.split(",")]
def is_r2(matrix):
"""Slot 2's row and column of three slots worked out by the app: entries 1, 3, 5 and 7 above 0 and other than
the sentinel, entries 2 and 6 the sentinel, the diagonal 0."""
try:
m = numbers(matrix)
except ValueError:
return False
return (len(m) == 9 and all(m[i] == 0 for i in (0, 4, 8)) and all(m[i] == SENTINEL for i in (2, 6)) and
all(m[i] > 0 and m[i] != SENTINEL for i in (1, 3, 5, 7)))
def four(matrix):
"""Entries 1, 3, 5 and 7: slot 2's row and column."""
m = numbers(matrix)
return [m[1], m[3], m[5], m[7]]
def g(value):
return "%g" % float(value)
class FilamentsTest:
def __init__(self, client, folder):
self.c = client
self.t = Checks()
self.folder = folder
# ---- Reads ----
def project_values(self, *keys):
items = self.c.call("project_get_settings", keys=list(keys), include_meta=False)["items"]
return {i["key"]: i["value"] for i in items}
def slots(self):
return self.project_values("filament_is_mixed")["filament_is_mixed"]
def dialogs(self):
return [{"title": d.get("title"), "buttons": [b.get("label") for b in d.get("buttons", [])]}
for d in self.c.call("app_state").get("dialogs", [])]
def state(self):
"""The raw state: each slot's preset, the tab's preset and whether it is modified, each slot's
slow_down_layer_time, the colours, the matrix and the open dialogs' titles."""
app = self.c.call("app_state")
presets = app["presets"]["filaments"]
tab = [(i["name"], bool(i.get("modified"))) for i in self.c.call("preset_list", type="filament", limit=500)["items"]
if i.get("selected")]
edits = [self.c.call("settings_get", type="filament", filament_slot=n, keys=["slow_down_layer_time"],
include_meta=False)["items"][0]["value"] for n in range(1, len(presets) + 1)]
project = self.project_values("filament_colour", "flush_volumes_matrix")
return {"presets": presets, "tab": tab, "edits": edits, "colours": project["filament_colour"],
"matrix": project["flush_volumes_matrix"], "dialogs": [d.get("title") for d in app.get("dialogs", [])]}
@staticmethod
def text(state):
"""The state written as the entry writes it: `B X B | B* | 4,4,4 | cX | R2`, with the open dialogs after it."""
tab = " ".join(LETTER.get(name, name) + ("*" if modified else "") for name, modified in state["tab"])
matrix = MATRICES.get(state["matrix"]) or ("R2" if is_r2(state["matrix"]) else state["matrix"])
out = " | ".join([" ".join(LETTER.get(p, p) for p in state["presets"]), tab, ",".join(state["edits"]),
COLOURS.get(state["colours"], state["colours"]), matrix])
return out + (f" | dialogs {state['dialogs']}" if state["dialogs"] else "")
def state_is(self, label, want):
state = self.state()
self.t.equal(f"{label}: the state", self.text(state), want)
return state
def filaments(self):
"""Each object as its filament and, with several parts, its parts' filaments: `cube 1 (1, 2) · cylinder 2`."""
listing = self.c.call("object_list", limit=500)
objects = sorted([o for p in listing["plates"] for o in p["objects"]] + listing.get("outside", []),
key=lambda o: o["index"])
return " · ".join(f"{o['name']} {o['filament']}" + (
f" ({', '.join(str(p['filament']) for p in o['parts'])})" if len(o["parts"]) > 1 else "") for o in objects)
def item(self, key, target, **where):
"""One item of settings_get as {value, effective, source, parts}, fields the reply leaves out absent, and the
reply's note."""
reply = self.c.call("settings_get", target=target, keys=[key], include_meta=False, **where)
item = reply["items"][0]
return {k: item[k] for k in ("value", "effective", "source", "parts") if k in item}, reply.get("note")
def project(self):
"""The project's own settings, `colours | multiplier | matrix | plate type | tower`, with plate_list's plate 0
added where it disagrees with project_get_settings."""
v = self.project_values("filament_colour", "flush_multiplier", "flush_volumes_matrix", "curr_bed_type",
"wipe_tower_x", "wipe_tower_y")
tower = f"{g(v['wipe_tower_x'].split(',')[0])},{g(v['wipe_tower_y'].split(',')[0])}"
plate = self.c.call("plate_list", limit=500)["items"][0]
out = {"colours": v["filament_colour"], "multiplier": g(v["flush_multiplier"]),
"matrix": ",".join(g(x) for x in v["flush_volumes_matrix"].split(",")),
"bed": v["curr_bed_type"], "tower": tower}
plate_tower = ",".join(g(x) for x in plate.get("wipe_tower") or [])
if (plate.get("curr_bed_type"), plate_tower) != (out["bed"], tower):
out["plate_list"] = f"{plate.get('curr_bed_type')} {plate_tower}"
return out
def project_is(self, label, colours, multiplier, matrix, bed, tower, matrix_holds=None):
"""project() compared whole; a matrix the app works out is given as a name and checked by `matrix_holds`."""
got = self.project()
if matrix_holds is not None and matrix_holds(got["matrix"]):
got = dict(got, matrix=matrix)
text = " | ".join([got["colours"], got["multiplier"], got["matrix"], got["bed"], got["tower"]])
if "plate_list" in got:
text += f" | plate_list {got['plate_list']}"
self.t.equal(f"{label}: the project's settings", text, " | ".join([colours, multiplier, matrix, bed, tower]))
return got
def grams(self):
"""Each slot's model_g and flush_g, and the plate's filament_changes, from plate_slice_stats."""
summary = self.c.call("plate_slice_stats", plate=0)["summary"]
return {f["slot"]: (f["model_g"], f["flush_g"]) for f in summary["filaments"]}, summary["filament_changes"]
# ---- Calls ----
def run(self, tool, **args):
return run(self.c, tool, **args)
def idle(self):
wait(self.c, "idle")
def pick(self, slot, preset):
self.c.call("widget_click", target={"class": "PlaterPresetComboBox", "index": slot})
return self.c.call("widget_click", target={"row": SHOWN[preset]})
def tool(self, slot, name, changes=None):
args = {"type": "filament", "name": name, "filament_slot": slot}
if changes:
args["preset_changes"] = changes
return self.c.call("preset_select", **args)
def api(self, body):
return self.c.call("script_run", code=API % body)
@staticmethod
def script_result(reply):
if isinstance(reply, dict) and reply.get("status") == "finished":
return reply.get("result")
return {"script": reply}
def close_dialogs(self):
"""Closes what a call left open against the entry, so that the next case starts clean."""
for _ in range(5):
if not self.c.call("app_state").get("dialogs"):
return
self.c.call("dialog_answer", button="cancel")
wait(self.c, "no_dialog", 10)
def quiet(self, label, reply):
"""A call that opens nothing: its reply is not held by a dialog, and the wait for idle is met."""
held = isinstance(reply, dict) and reply.get("status") in ("blocked_by_dialog", "running")
self.t.check(f"{label}: no dialog opened", not held, reply)
if held:
self.close_dialogs()
self.c.await_job(reply, timeout=60)
self.idle()
return reply
def prompt(self, label, reply, answer, offers=("Transfer", "Discard", "Save"), lacks=()):
"""A call the prompt holds: it replies blocked_by_dialog, the prompt is the only dialog with the buttons it
offers, the answer closes it and the wait for the call's job is met. Returns the job's result."""
self.t.equal(f"{label}: the call replies blocked_by_dialog", reply.get("status"), "blocked_by_dialog")
if reply.get("status") == "running":
wait(self.c, "dialog", 10)
dialogs = self.dialogs()
buttons = dialogs[0]["buttons"] if dialogs else []
ok = ([d["title"] for d in dialogs] == [PROMPT] and all(b in buttons for b in offers) and
not any(b in buttons for b in lacks))
self.t.check(f"{label}: the prompt alone, offering {', '.join(offers)}" +
(f" and not {', '.join(lacks)}" if lacks else ""), ok, dialogs)
if "job" not in reply:
return reply
self.c.call("dialog_answer", button=answer)
try:
result = wait(self.c, "job", 30, job=reply["job"])
except TimeoutError as e:
self.t.check(f"{label}: the wait for the call's job is met", False, e)
self.close_dialogs()
result = self.c.await_job(reply, timeout=60)
except orca_mcp.McpError as e:
result = {"ERROR": str(e)}
self.idle()
return result
def tool_reply(self, label, reply, **want):
"""The reply's selected, shown, discarded and modified, each as `want` gives it (None: absent)."""
self.t.equal(f"{label}: the reply", {k: reply.get(k) for k in want}, want)
# ---- Arranging ----
def start(self, name, count):
"""A new project in the Prepare view, Auto-flush All, and `count` filament slots."""
self.run("project_new", discard_changes=True, preset_changes="discard")
self.run("view_set", tab="prepare")
self.idle()
self.flush_preference(name, "All")
for _ in range(32):
try:
self.c.call("filament_delete")
except orca_mcp.McpError:
break
for _ in range(count - 1):
self.run("filament_add")
self.idle()
self.t.equal(f"{name}: the start's slots", self.slots(), ",".join(["0"] * count))
def flush_preference(self, label, which):
self.run("preferences_set", values={"auto_calculate_flush": FLUSH[which]})
got = self.c.call("preferences_get", keys=["auto_calculate_flush"])["items"][0]["value"]
self.t.equal(f"{label}: Auto-flush reads {which}", got, FLUSH[which])
def drop_edits(self):
"""Drops the tab's unsaved changes through a slot that holds the preset the tab edits."""
state = self.state()
if not state["tab"] or not state["tab"][0][1]:
return
name = state["tab"][0][0]
slot = state["presets"].index(name) + 1 if name in state["presets"] else 1
reply = self.c.call("settings_set", type="filament", filament_slot=slot, reset_all=True)
if isinstance(reply, dict) and reply.get("status") == "blocked_by_dialog":
self.c.call("dialog_answer", button="Discard")
self.c.await_job(reply, timeout=60)
def arrange(self, label, presets, dirty, want):
"""The state a case starts from, checked as the row's start."""
self.drop_edits()
for slot, name in enumerate(presets, 1):
self.run("preset_select", type="filament", name=name, filament_slot=slot, preset_changes="discard")
self.run("settings_set", type="filament", filament_slot=1, reset_all=True)
n = len(presets)
self.run("project_set_settings", values={
"filament_colour": GREYS[:n],
"flush_volumes_matrix": [0 if i == j else SENTINEL for i in range(n) for j in range(n)]})
if dirty:
self.run("settings_set", type="filament", filament_slot=1, values={"slow_down_layer_time": 9})
self.idle()
self.state_is(f"{label}: the start", want)
# ---- Scenarios ----
def hidden(self):
s = "hidden filaments"
self.start(s, 1)
self.arrange(s, [B], False, "B | B | 4 | #111111 | 0")
queries = {X: "FilAr PLA Blanco Calido", M: "Bambu PLA Matte", S: "Bambu Support For PLA",
A: "Bambu Support for ABS"}
def found(query, **args):
return {i["name"]: i for i in self.c.call("preset_list", type="filament", query=query, limit=500,
**args)["items"]}
listed = {LETTER[p]: (p in found(q), found(q, include_uninstalled=True).get(p, {}).get("installed", "absent"))
for p, q in queries.items()}
self.t.equal(f"{s} 1: hidden, and listed with include_uninstalled as not installed", listed,
{"X": (False, False), "M": (False, False), "S": (False, False), "A": (False, False)})
self.state_is(f"{s} 1", "B | B | 4 | #111111 | 0")
for step, preset, want in [(2, X, "X | X | 4 | #FFF8E7 | 0"), (3, M, "M | M | 4 | #FFF8E7 | 0"),
(4, S, "S | S | 8 | #FFF8E7 | 0"), (5, A, "A | A | 12 | #FFF8E7 | 0")]:
reply = self.quiet(f"{s} {step}", self.tool(1, queries[preset]))
self.tool_reply(f"{s} {step}", reply, selected=preset, shown=preset)
self.state_is(f"{s} {step}", want)
reply = self.quiet(f"{s} 6", self.tool(1, "Bambu PLA Basic"))
self.tool_reply(f"{s} 6", reply, selected=B, shown=None)
self.state_is(f"{s} 6", "B | B | 4 | #FFF8E7 | 0")
shown = {LETTER[p]: found(q).get(p, {"absent": True}).get("installed", "no field") for p, q in queries.items()}
self.t.equal(f"{s} 7: each listed with no installed field", shown,
{"X": "no field", "M": "no field", "S": "no field", "A": "no field"})
self.state_is(f"{s} 7", "B | B | 4 | #FFF8E7 | 0")
def one_slot_pla(self):
s = "one slot, X"
self.start(s, 1)
clean, dirty = "B | B | 4 | #111111 | 0", "B | B* | 9 | #111111 | 0"
after1, after4 = "X | X | 4 | #FFF8E7 | 0", "X | X* | 9 | #FFF8E7 | 0"
after6 = "B | B* | 9 | #FFF8E7 | 0"
transferred = {"selected": X, "modified": {"filament": {"name": X, "keys": ["slow_down_layer_time"]}},
"discarded": None}
discarded = {"selected": X, "discarded": {"filament": {"name": B, "keys": ["slow_down_layer_time"]}},
"modified": None}
def case(row, is_dirty):
label = f"{s} {row}"
self.arrange(label, [B], is_dirty, dirty if is_dirty else clean)
return label
label = case(1, False)
self.quiet(label, self.pick(1, X))
self.state_is(label, after1)
label = case(2, False)
self.tool_reply(label, self.quiet(label, self.tool(1, X)), selected=X, shown=None, discarded=None,
modified=None)
self.state_is(label, after1)
label = case(3, False)
result = self.script_result(self.quiet(label, self.api(commit_form(1, X))))
self.t.equal(f"{label}: the commit", result, commit(X))
self.state_is(label, after1)
for row, answer, want in [(4, "Transfer", after4), (5, "Discard", after1), (6, "cancel", after6)]:
label = case(row, True)
self.prompt(label, self.pick(1, X), answer)
self.state_is(label, want)
label = case(7, True)
self.tool_reply(label, self.quiet(label, self.tool(1, X, "transfer")), **transferred)
self.state_is(label, after4)
label = case(8, True)
self.tool_reply(label, self.quiet(label, self.tool(1, X, "discard")), **discarded)
self.state_is(label, after1)
cancelled = {"selected": B, "modified": {"filament": {"name": B, "keys": ["slow_down_layer_time"]}},
"discarded": None}
for row, answer, want, reply in [(9, "Transfer", after4, transferred), (10, "Discard", after1, discarded),
(11, "cancel", after6, cancelled)]:
label = case(row, True)
result = self.prompt(label, self.tool(1, X), answer)
self.tool_reply(f"{label}: the job's result", result, **reply)
self.state_is(label, want)
for row, answer, want, result in [(12, "Transfer", after4, commit(X, dirty=True)),
(13, "Discard", after1, commit(X)),
(14, "cancel", dirty, canceled(X, 1))]:
label = case(row, True)
got = self.script_result(self.prompt(label, self.api(commit_form(1, X)), answer))
self.t.equal(f"{label}: the commit", got, result)
self.state_is(label, want)
def one_slot_support(self):
s = "one slot, A"
self.start(s, 1)
clean, dirty = "B | B | 4 | #111111 | 0", "B | B* | 9 | #111111 | 0"
after1 = "A | A | 12 | #111111 | 0"
no_transfer = {"offers": ("Discard", "Save"), "lacks": ("Transfer",)}
discarded = {"discarded": {"filament": {"name": B, "keys": ["slow_down_layer_time"]}}}
def case(row, is_dirty):
label = f"{s} {row}"
self.arrange(label, [B], is_dirty, dirty if is_dirty else clean)
return label
label = case(1, False)
self.quiet(label, self.pick(1, A))
self.state_is(label, after1)
label = case(2, False)
self.tool_reply(label, self.quiet(label, self.tool(1, A)), selected=A)
self.state_is(label, after1)
label = case(3, False)
result = self.script_result(self.quiet(label, self.api(commit_form(1, A))))
self.t.equal(f"{label}: the commit", result, commit(A))
self.state_is(label, after1)
for row, answer, want in [(4, "Discard", after1), (5, "cancel", dirty)]:
label = case(row, True)
self.prompt(label, self.pick(1, A), answer, **no_transfer)
self.state_is(label, want)
label = case(6, True)
self.t.refused(f"{label}: refused", lambda: self.tool(1, A, "transfer"), code="transfer_not_offered")
self.state_is(label, dirty)
label = case(7, True)
self.tool_reply(label, self.quiet(label, self.tool(1, A, "discard")), **discarded)
self.state_is(label, after1)
label = case(8, True)
self.tool_reply(f"{label}: the job's result", self.prompt(label, self.tool(1, A), "Discard", **no_transfer),
**discarded)
self.state_is(label, after1)
label = case(9, True)
result = self.prompt(label, self.tool(1, A), "cancel", **no_transfer)
self.tool_reply(f"{label}: the job's result", result, selected=B)
self.state_is(label, dirty)
for row, answer, want, result in [(10, "Discard", after1, commit(A)), (11, "cancel", dirty, canceled(A, 1))]:
label = case(row, True)
got = self.script_result(self.prompt(label, self.api(commit_form(1, A)), answer, **no_transfer))
self.t.equal(f"{label}: the commit", got, result)
self.state_is(label, want)
def one_slot_forms(self):
s = "one slot, no preset named"
self.start(s, 1)
clean, dirty = "B | B | 4 | #111111 | 0", "B | B* | 9 | #111111 | 0"
after2 = "B | B* | 8 | #111111 | 0"
rows = [(1, False, commit_form(1), clean, commit(B, selection=False, assignment=False)),
(2, False, update_form(1, "slow_down_layer_time", "8"), after2, "returned"),
(3, False, update_form("slow_down_layer_time", "8"), after2, "returned"),
(4, True, commit_form(1), dirty, commit(B, selection=False, assignment=False, dirty=True)),
(5, True, update_form(1, "slow_down_layer_time", "8"), after2, "returned"),
(6, True, update_form("slow_down_layer_time", "8"), after2, "returned"),
(7, True, commit_form(1, "Bambu PLA Basic"), dirty,
commit(B, selection=False, assignment=False, dirty=True))]
for row, is_dirty, body, want, result in rows:
label = f"{s} {row}"
self.arrange(label, [B], is_dirty, dirty if is_dirty else clean)
got = self.script_result(self.quiet(label, self.api(body)))
self.t.equal(f"{label}: what the call returns", got, result)
self.state_is(label, want)
def auto_flush(self):
s = "Auto-flush"
self.start(s, 3)
start = "B B B | B | 4,4,4 | c3 | S3"
table = {"All": {X: ("cX", "R2"), M: ("c3", "R2"), S: ("c3", "Sup")},
"Color": {X: ("cX", "R2"), M: ("c3", "S3"), S: ("c3", "S3")},
"None": {X: ("cX", "S3"), M: ("c3", "S3"), S: ("c3", "S3")}}
colour_change = {"All": "R2", "Color": "R2", "None": "S3"}
x_entries = {}
for which, rows in table.items():
self.flush_preference(s, which)
routes = []
for preset, (colours, matrix) in rows.items():
edits = "4,8,4" if preset == S else "4,4,4"
for route in ("pick", "tool", "api"):
label = f"{s} {which}, {LETTER[preset]} by {route}"
self.arrange(label, [B, B, B], False, start)
if route == "pick":
self.quiet(label, self.pick(2, preset))
elif route == "tool":
self.quiet(label, self.tool(2, preset))
else:
got = self.script_result(self.quiet(label, self.api(commit_form(2, preset))))
self.t.equal(f"{label}: the commit", got, commit(preset, shared=[2]))
tab = LETTER[preset] if route == "api" else "B"
state = self.state_is(label, f"B {LETTER[preset]} B | {tab} | {edits} | {colours} | {matrix}")
if preset == X and matrix == "R2" and is_r2(state["matrix"]):
routes.append(four(state["matrix"]))
if which == "All":
m = numbers(state["matrix"])
self.t.check(f"{label}: the volumes into X above those out of it",
min(m[1], m[7]) > max(m[3], m[5]), state["matrix"])
label = f"{s} {which}, the colour picker's change"
self.arrange(label, [B, B, B], False, start)
self.run("project_set_settings", values={"filament_colour": {"index": 1, "value": "#FFF8E7"}})
self.idle()
state = self.state_is(label, f"B B B | B | 4,4,4 | cX | {colour_change[which]}")
if colour_change[which] == "R2":
self.t.check(f"{s} {which}: the three routes of X give the same four entries",
len(routes) == 3 and all(e == routes[0] for e in routes), routes)
# Slot 2 keeps B, whose cut retraction the calculator takes off the flush out of the slot.
changed = four(state["matrix"]) if is_r2(state["matrix"]) else None
self.t.check(f"{s} {which}: the colour change gives the routes' entries into slot 2, and lower ones out "
f"of it", bool(routes) and changed is not None and
(changed[0], changed[3]) == (routes[0][0], routes[0][3]) and
changed[1] < routes[0][1] and changed[2] < routes[0][2], (changed, routes))
x_entries[which] = routes[0] if routes else None
self.t.equal(f"{s}: Color gives what All gave for X", x_entries.get("Color"), x_entries.get("All"))
def three_slots_dirty(self):
s = "three slots, unsaved changes"
self.start(s, 3)
start, start_m = "B B B | B* | 9,9,9 | c3 | S3", "B M B | B* | 9,4,9 | c3 | S3"
after1 = "B X B | B* | 9,4,9 | cX | R2"
kept = {"selected": X, "modified": {"filament": {"name": B, "keys": ["slow_down_layer_time"]}},
"discarded": None}
label = f"{s} 1"
self.arrange(label, [B, B, B], True, start)
self.quiet(label, self.pick(2, X))
self.state_is(label, after1)
for row, changes in [(2, None), (3, "transfer"), (4, "discard")]:
label = f"{s} {row}"
self.arrange(label, [B, B, B], True, start)
self.tool_reply(label, self.quiet(label, self.tool(2, X, changes)), **kept)
self.state_is(label, after1)
offers = {"offers": ("Transfer", "Discard")}
for row, answer, want, result in [
(5, "Transfer", "B X B | X* | 4,9,4 | cX | R2", commit(X, shared=[2], dirty=True)),
(6, "Discard", "B X B | X | 4,4,4 | cX | R2", commit(X, shared=[2])),
(7, "cancel", start, canceled(X, 2))]:
label = f"{s} {row}"
self.arrange(label, [B, B, B], True, start)
got = self.script_result(self.prompt(label, self.api(commit_form(2, X)), answer, **offers))
self.t.equal(f"{label}: the commit", got, result)
self.state_is(label, want)
for row, body in [(8, commit_form(2)), (9, update_form(2, "slow_down_layer_time", "8"))]:
label = f"{s} {row}"
self.arrange(label, [B, M, B], True, start_m)
got = self.script_result(self.prompt(label, self.api(body), "cancel", **offers))
self.t.equal(f"{label}: raised", got, canceled(M, 2))
self.state_is(label, start_m)
def three_slots_forms(self):
s = "three slots, other forms"
self.start(s, 3)
start, start_m = "B B B | B | 4,4,4 | c3 | S3", "B M B | B | 4,4,4 | c3 | S3"
label = f"{s} 1"
self.arrange(label, [B, B, B], False, start)
self.quiet(label, self.c.call("widget_set_value", target={"class": "PlaterPresetComboBox", "index": 2},
value="FilAr PLA Blanco Calido"))
self.state_is(label, "B X B | B | 4,4,4 | cX | R2")
label = f"{s} 2"
self.arrange(label, [B, B, B], False, start)
got = self.script_result(self.quiet(label, self.api(begin_form(2, X))))
self.t.equal(f"{label}: the transaction", got, {"target_name": X, "selection_changed": True, "slot_number": 2})
self.state_is(label, "B X B | X | 4,4,4 | cX | R2")
after5 = "B M B | M* | 4,8,4 | c3 | S3"
rows = [(3, commit_form(2, "Bambu PLA Matte"), "B M B | M | 4,4,4 | c3 | S3",
commit(M, assignment=False, shared=[2])),
(4, commit_form(2), "B M B | M | 4,4,4 | c3 | S3", commit(M, assignment=False, shared=[2])),
(5, set_commit_form(2, "slow_down_layer_time", "8"), after5,
commit(M, assignment=False, shared=[2], keys=["slow_down_layer_time"], dirty=True)),
(6, update_form(2, "slow_down_layer_time", "8"), after5, "returned"),
(7, update_form("slow_down_layer_time", "8"), "B M B | B* | 8,4,8 | c3 | S3", "returned")]
for row, body, want, result in rows:
label = f"{s} {row}"
self.arrange(label, [B, M, B], False, start_m)
got = self.script_result(self.quiet(label, self.api(body)))
self.t.equal(f"{label}: what the call returns", got, result)
self.state_is(label, want)
def refusals(self):
s = "three slots, refusals"
self.start(s, 3)
start = "B B B | B | 4,4,4 | c3 | S3"
out_of_range = ("Filament slot %d is out of range; slot numbers are 1-based and this printer has 3 filament "
"slot(s)")
not_offered = 'The selector of filament slot 2 does not offer "No Such Filament".'
incompatible = '"Bambu PLA Basic @BBL A1" is not compatible with the selected printer.'
def case(row):
label = f"{s} {row}"
self.arrange(label, [B, B, B], False, start)
return label
def api_raises(row, body, want):
label = case(row)
got = self.script_result(self.quiet(label, self.api(body)))
self.t.equal(f"{label}: raised", got, want)
self.state_is(label, start)
label = case(1)
self.t.refused(f"{label}: refused", lambda: self.tool(5, X), code="no_such_slot",
words="Filament slot 5 does not exist (the slots are 1..3)")
self.state_is(label, start)
api_raises(2, commit_form(5, X), raised("IndexError", out_of_range % 5))
api_raises(3, commit_form(0, X), raised("IndexError", out_of_range % 0))
api_raises(4, update_form(5, "slow_down_layer_time", "8"), raised("IndexError", out_of_range % 5))
label = case(5)
text = self.t.refused(f"{label}: refused", lambda: self.tool(2, "No Such Filament"),
code="preset_not_offered", words=not_offered)
self.t.check(f"{label}: the refusal starts with its reason", (text or "").startswith(not_offered), text)
self.state_is(label, start)
api_raises(6, commit_form(2, "No Such Filament"), raised("ValueError", not_offered))
label = case(7)
text = self.t.refused(f"{label}: refused", lambda: self.tool(2, "Bambu PLA Basic @BBL A1"),
code="preset_incompatible", words=incompatible)
self.t.check(f"{label}: the refusal starts with its reason", (text or "").startswith(incompatible), text)
self.state_is(label, start)
api_raises(8, commit_form(2, "Bambu PLA Basic @BBL A1"), raised("ValueError", incompatible))
label = case(9)
got = self.script_result(self.quiet(label, self.api(begin_form("FilAr PLA Blanco Calido"))))
self.t.check(f"{label}: raised ValueError",
isinstance(got, dict) and got.get("raised", {}).get("type") == "ValueError" and
got["raised"].get("message", "").startswith(
'begin_update on the filament editor takes (slot_number, preset_name="")'), got)
self.state_is(label, start)
def names(query, **args):
return {i["name"]: i for i in self.c.call("preset_list", type="filament", query=query, limit=500,
**args)["items"]}
label = case(10)
first, second = names("Bambu PETG"), names("Bambu PETG", include_uninstalled=True)
self.t.equal(f"{label}: hidden, then listed as not installed",
{LETTER[p]: (p in first, second.get(p, {}).get("installed", "absent")) for p in (G, H)},
{"G": (False, False), "H": (False, False)})
self.state_is(label, start)
label = case(11)
reply = self.quiet(label, self.tool(2, "Bambu PETG Basic"))
self.tool_reply(label, reply, selected=G, shown=G)
self.state_is(label, "B G B | B | 4,12,4 | c3 | R2")
self.t.check(f"{label}: preset_list lists G", G in names("Bambu PETG Basic"), names("Bambu PETG Basic"))
label = case(12)
got = self.script_result(self.quiet(label, self.api(commit_form(2, H))))
self.t.equal(f"{label}: nothing raised, and the slot assigned",
{k: got.get(k) for k in ("raised", "slot_assignment_changed")} if isinstance(got, dict) else got,
{"raised": None, "slot_assignment_changed": True})
self.state_is(label, "B H B | H | 4,10,4 | c3 | R2")
self.t.check(f"{label}: preset_list lists H", H in names("Bambu PETG HF"), names("Bambu PETG HF"))
def add_objects(self):
self.run("object_add_primitive", **CUBE)
self.run("object_add_primitive", **CYLINDER)
self.run("part_add", object=0, type="part", shape="cube", size=[5, 5, 5])
self.idle()
def slice_ok(self, label):
reply = self.run("plate_slice")
self.t.equal(f"{label}: the slice", [p.get("outcome") for p in reply.get("plates", [])], ["ok"])
return self.grams()
def objects_and_parts(self):
s = "filaments of objects and parts"
self.start(s, 2)
for slot in (1, 2):
self.run("preset_select", type="filament", name=B, filament_slot=slot, preset_changes="discard")
self.t.equal(f"{s}: the start's presets", self.c.call("app_state")["presets"]["filaments"], [B, B])
self.add_objects()
self.t.equal(f"{s}: the start's filaments", self.filaments(), "cube 1 (1, 1) · cylinder 1")
one = {"value": "1", "effective": "1", "source": "object"}
two = {"value": "2", "effective": "2", "source": "object"}
cube_start = dict(one, parts=[{"part": 1, "value": "1"}])
self.t.equal(f"{s}: the start's cylinder", self.item("extruder", "object", object=1)[0], one)
self.t.equal(f"{s}: the start's cube", self.item("extruder", "object", object=0)[0], cube_start)
grams, changes = self.slice_ok(f"{s}: the control")
control = grams
self.t.check(f"{s}: the control prints with slot 1 alone",
grams[1][0] > 0 and grams[2] == (0, 0) and changes == 0, (grams, changes))
reply = self.run("settings_set", target="object", object=1, values={"extruder": 2})
self.t.equal(f"{s} 1: the reply", (reply.get("applied", {}).get("extruder"),
[o.get("index") for o in reply.get("objects", [])]), ("2", [1]))
self.t.equal(f"{s} 1", self.filaments(), "cube 1 (1, 1) · cylinder 2")
self.t.equal(f"{s} 1: the cylinder", self.item("extruder", "object", object=1)[0], two)
self.t.equal(f"{s} 1: the cube", self.item("extruder", "object", object=0)[0], cube_start)
self.run("undo", history="project")
self.t.equal(f"{s} 2", self.filaments(), "cube 1 (1, 1) · cylinder 1")
self.t.equal(f"{s} 2: the cylinder", self.item("extruder", "object", object=1)[0], one)
self.run("redo", history="project")
self.t.equal(f"{s} 3", self.filaments(), "cube 1 (1, 1) · cylinder 2")
self.t.equal(f"{s} 3: the cylinder", self.item("extruder", "object", object=1)[0], two)
reply = self.run("settings_set", target="part", object=1, part=0, values={"extruder": 1})
self.t.equal(f"{s} 4: the reply", (reply.get("applied", {}).get("extruder"), reply.get("note")),
("1", "A single-part object's filament is the object's; it was set there."))
self.t.equal(f"{s} 4", self.filaments(), "cube 1 (1, 1) · cylinder 1")
self.t.equal(f"{s} 4: the cylinder", self.item("extruder", "object", object=1)[0], one)
part_two = {"value": "2", "effective": "2", "source": "part"}
cube_part_two = dict(one, parts=[{"part": 1, "value": "2"}])
reply = self.run("settings_set", target="part", object=0, part=1, values={"extruder": 2})
parts = [{"object": p.get("object"), "part": p.get("part")} for p in reply.get("parts", [])]
self.t.equal(f"{s} 5: the reply", (reply.get("applied", {}).get("extruder"), parts, reply.get("note")),
("2", [{"object": 0, "part": 1}], None))
self.t.equal(f"{s} 5", self.filaments(), "cube 1 (1, 2) · cylinder 1")
self.t.equal(f"{s} 5: the cube's part", self.item("extruder", "part", object=0, part=1),
(part_two, PART_NOTE))
self.t.equal(f"{s} 5: the cube", self.item("extruder", "object", object=0), (cube_part_two, PART_NOTE))
grams, _ = self.slice_ok(f"{s} 6")
step6 = grams
self.t.check(f"{s} 6: the cube's part prints with slot 2", grams[2][0] > 0 and control[2][0] == 0,
(grams, control))
self.t.equal(f"{s} 6", self.filaments(), "cube 1 (1, 2) · cylinder 1")
reply = self.run("settings_set", target="part", object=0, part=1, values={"extruder": None})
self.t.equal(f"{s} 7: the reply", reply.get("applied", {}).get("extruder"), "1")
self.t.equal(f"{s} 7", self.filaments(), "cube 1 (1, 1) · cylinder 1")
self.t.equal(f"{s} 7: the cube's part", self.item("extruder", "part", object=0, part=1)[0],
{"value": "1", "effective": "1", "source": "part"})
self.run("settings_set", target="part", object=0, part=1, values={"extruder": 2})
self.run("settings_set", target="object", object=1, values={"extruder": 2})
self.t.equal(f"{s} 8", self.filaments(), "cube 1 (1, 2) · cylinder 2")
self.t.equal(f"{s} 8: the cube's part", self.item("extruder", "part", object=0, part=1)[0], part_two)
self.t.equal(f"{s} 8: the cylinder", self.item("extruder", "object", object=1)[0], two)
reply = self.run("settings_set", target="object", object=0, values={"extruder": 2, "wall_loops": 5})
self.t.equal(f"{s} 9: the reply", reply.get("applied"), {"extruder": "2", "wall_loops": "5"})
self.t.equal(f"{s} 9", self.filaments(), "cube 2 (2, 2) · cylinder 2")
self.t.equal(f"{s} 9: the cube", self.item("extruder", "object", object=0)[0], two)
self.t.equal(f"{s} 9: the cube's walls", self.item("wall_loops", "object", object=0)[0],
{"value": "5", "effective": "5", "source": "object"})
self.run("undo", history="project")
self.t.equal(f"{s} 10", self.filaments(), "cube 1 (1, 2) · cylinder 2")
self.t.equal(f"{s} 10: the cube", self.item("extruder", "object", object=0)[0], cube_part_two)
self.t.equal(f"{s} 10: the cube's walls", self.item("wall_loops", "object", object=0)[0],
{"value": None, "effective": "2", "source": "global"})
grams, changes = self.slice_ok(f"{s} 11")
self.t.check(f"{s} 11: both slots print, the cylinder with slot 2 too",
grams[2][0] > step6[2][0] and grams[1][0] > 0 and changes > 0, (grams, changes, step6))
self.t.equal(f"{s} 11", self.filaments(), "cube 1 (1, 2) · cylinder 2")
def save_and_reopen(self, name):
path = os.path.join(self.folder, name)
self.run("project_save", path=path, overwrite=True)
self.run("project_new", discard_changes=True)
self.run("project_open", path=path)
self.idle()
def project_settings(self):
s = "the project's own settings"
self.start(s, 2)
self.run("preset_select", type="filament", name=B, filament_slot=1, preset_changes="discard")
self.run("preset_select", type="filament", name=M, filament_slot=2, preset_changes="discard")
self.add_objects()
self.run("settings_set", target="part", object=0, part=1, values={"extruder": 2})
self.run("settings_set", target="object", object=1, values={"extruder": 2})
self.run("project_set_settings", values={
"filament_colour": ["#111111", "#222222"], "flush_volumes_matrix": [0, 777, 777, 0], "flush_multiplier": 1,
"curr_bed_type": "Cool Plate", "wipe_tower_x": {"index": 0, "value": 60},
"wipe_tower_y": {"index": 0, "value": 150}})
self.idle()
self.t.equal(f"{s}: the start's filaments", self.filaments(), "cube 1 (1, 2) · cylinder 2")
self.t.equal(f"{s}: the start's presets", self.c.call("app_state")["presets"]["filaments"], [B, M])
self.project_is(f"{s}: the start", "#111111;#222222", "1", "0,777,777,0", "Cool Plate", "60,150")
items = {i["key"]: i for i in self.c.call("project_get_settings", keys=[
"filament_is_mixed", "curr_bed_type", "prime_volume_mode"])["items"]}
self.t.equal(f"{s} 1: the mixed slots, read-only",
(items["filament_is_mixed"]["value"], items["filament_is_mixed"]["meta"].get("read_only")),
("0,0", True))
offered = items["curr_bed_type"]["meta"].get("offered", [])
self.t.check(f"{s} 1: the plate types offered include Cool Plate and Textured PEI Plate",
"Cool Plate" in offered and "Textured PEI Plate" in offered, offered)
self.t.equal(f"{s} 1: no purge mode to choose", (items["prime_volume_mode"]["value"],
items["prime_volume_mode"]["meta"].get("offered")),
("Default", []))
self.project_is(f"{s} 1", "#111111;#222222", "1", "0,777,777,0", "Cool Plate", "60,150")
reply = self.run("project_set_settings", values={"filament_colour": {"index": 0, "value": "#ffffff"}})
self.t.equal(f"{s} 2: the reply", reply.get("applied", {}).get("filament_colour"), "#FFFFFF;#222222")
def into_white(matrix):
m = numbers(matrix)
return len(m) == 4 and m[0] == 0 and m[3] == 0 and SENTINEL not in (m[1], m[2]) and m[2] > m[1]
self.project_is(f"{s} 2", "#FFFFFF;#222222", "1", "0,<a>,<b>,0", "Cool Plate", "60,150", into_white)
self.run("project_set_settings", values={"flush_volumes_matrix": [0, 777, 777, 0]})
self.run("project_set_settings", values={
"filament_colour": {"index": 1, "value": "#000000"}, "flush_multiplier": 0.7,
"flush_volumes_matrix": {"index": 1, "value": 400}, "curr_bed_type": "Textured PEI Plate"})
def c_worked_out(matrix):
m = numbers(matrix)
return len(m) == 4 and m[0] == 0 and m[1] == 400 and m[3] == 0 and m[2] not in (SENTINEL, 400)
pei = "Textured PEI Plate"
self.project_is(f"{s} 3", "#FFFFFF;#000000", "0.7", "0,400,<c>,0", pei, "60,150", c_worked_out)
self.run("project_set_settings", values={"flush_volumes_matrix": [0, 400, 300, 0]})
self.project_is(f"{s} 4", "#FFFFFF;#000000", "0.7", "0,400,300,0", pei, "60,150")
reply = self.run("project_set_settings", values={"wipe_tower_x": {"index": 0, "value": 150},
"wipe_tower_y": {"index": 0, "value": 180}})
self.t.equal(f"{s} 5: the reply has no note", reply.get("note"), None)
after = ("#FFFFFF;#000000", "0.7", "0,400,300,0", pei, "150,180")
self.project_is(f"{s} 5", *after)
self.run("project_set_settings", values={"wipe_tower_x": {"index": 0, "value": 40}})
self.project_is(f"{s} 6", "#FFFFFF;#000000", "0.7", "0,400,300,0", pei, "40,180")
self.run("undo", history="project")
self.project_is(f"{s} 7: the move was one undo step", *after)
refusals = [
(8, {"filament_is_mixed": "1"},
"filament_is_mixed is read-only: mixed filaments are made in the sidebar's mixed filament list"),
(9, {"filament_colour": {"index": 1, "value": "white"}, "flush_multiplier": 0.5},
'Slot 2\'s colour "white" is not #RRGGBB'),
(10, {"prime_volume_mode": "Saving"}, "prime_volume_mode: this printer has no purge mode to choose"),
(11, {"flush_volumes_matrix": {"index": 0, "value": 10}},
"flush_volumes_matrix[0] (nozzle 1, from slot 1 to slot 1) must be 0: no flush from a filament to itself"),
(12, {"wipe_tower_x": {"index": 0, "value": 300}}, "The prime tower of plate 0 would be off the plate"),
]
for step, values, words in refusals:
self.t.refused(f"{s} {step}: refused", lambda: self.c.call("project_set_settings", values=values),
words=words)
self.project_is(f"{s} {step}", *after)
self.t.equal(f"{s} 8: the slots", self.slots(), "0,0")
self.t.equal(f"{s} 10: the purge mode", self.project_values("prime_volume_mode")["prime_volume_mode"],
"Default")
grams13, changes13 = self.slice_ok(f"{s} 13")
self.t.check(f"{s} 13: each slot prints and flushes, with filament changes",
all(grams13[slot][0] > 0 and grams13[slot][1] > 0 for slot in (1, 2)) and changes13 > 0,
(grams13, changes13))
self.project_is(f"{s} 13", *after)
self.run("project_set_settings", values={"flush_volumes_matrix": {"index": 1, "value": 200}})
grams14, changes14 = self.slice_ok(f"{s} 14")
self.project_is(f"{s} 14", "#FFFFFF;#000000", "0.7", "0,200,300,0", pei, "150,180")
self.t.check(f"{s} 14: slot 2 flushes less", grams14[2][1] < grams13[2][1], (grams14, grams13))
self.t.check(f"{s} 14: slot 1's flush and the changes as after 13",
abs(grams14[1][1] - grams13[1][1]) <= 0.01 and changes14 == changes13,
(grams14, changes14, grams13, changes13))
self.run("project_set_settings", values={"flush_multiplier": 1.4})
grams15, _ = self.slice_ok(f"{s} 15")
after15 = ("#FFFFFF;#000000", "1.4", "0,200,300,0", pei, "150,180")
self.project_is(f"{s} 15", *after15)
self.t.check(f"{s} 15: each slot flushes more", all(grams15[slot][1] > grams14[slot][1] for slot in (1, 2)),
(grams15, grams14))
self.save_and_reopen("filaments.3mf")
label = f"{s} 16: the project file keeps them"
self.project_is(label, *after15)
self.t.equal(f"{label}: the filaments", self.filaments(), "cube 1 (1, 2) · cylinder 2")
self.t.equal(f"{label}: the presets", self.c.call("app_state")["presets"]["filaments"], [B, M])
self.t.equal(f"{label}: the slots", self.slots(), "0,0")
def run_all(self):
self.run("action_run", id="orca_command:mode_simple:orca")
self.t.equal("Simple mode", self.c.call("app_state").get("mode"), "simple")
for name, scenario in [("hidden filaments", self.hidden), ("one slot, X", self.one_slot_pla),
("one slot, A", self.one_slot_support),
("one slot, no preset named", self.one_slot_forms),
("Auto-flush", self.auto_flush), ("three slots, unsaved changes", self.three_slots_dirty),
("three slots, other forms", self.three_slots_forms),
("three slots, refusals", self.refusals),
("filaments of objects and parts", self.objects_and_parts),
("the project's own settings", self.project_settings)]:
self.t.scenario(name, scenario)
self.c.call("preferences_set", values={"auto_calculate_flush": "all"})
self.run("project_new", discard_changes=True, preset_changes="discard")
return self.t.exit_code()
def main():
client, _ = orca_mcp.session_client()
with tempfile.TemporaryDirectory(prefix="orca-filaments-") as folder:
return FilamentsTest(client, folder).run_all()
if __name__ == "__main__":
sys.exit(main())
File diff suppressed because it is too large. Load diff
File diff suppressed because it is too large. Load diff
+744
View File
@@ -0,0 +1,744 @@
#!/usr/bin/env python3
"""The generic GUI tools on the app's own widgets, as the test_gui_tools entry of
tools/mcp/test-entries/gui_tools.md designs them.
tools/mcp/orca_mcp.py launch
tools/mcp/test_gui_tools.py [--out DIR]
Context menus and a button's menu listed and run by path without being shown, the Edit menu's items, the rows of
the object list, of Compare presets and of the parameter table, the print button's popup, a drop-down list, and
Orca's web dialogs, driven as an agent drives any widget. Every menu item, row and page element the test runs or
clicks is checked by what it does to the project, the selection, the camera or the settings. It runs on the
harness's default printer, the Bambu Lab X1 Carbon 0.4, and exits 0 when every check passes. The pictures and
project files it saves go to --out, else to a new temporary folder.
"""
import argparse
import json
import os
import re
import sys
import tempfile
import time
import zipfile
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import orca_mcp # noqa: E402
from checks import Checks, plates, refusal, run, wait # noqa: E402
ADD_CUBE = "orca_command:add_primitive_cube:orca"
UNDO = "orca_command:undo:orca"
REDO = "orca_command:redo:orca"
PRESET_BUNDLE = "orca_command:preset_bundle:orca"
SETUP_WIZARD = "orca_command:help_setup_wizard:orca"
PRINTER = "Bambu Lab X1 Carbon 0.4 nozzle"
PLA = "Bambu PLA Basic @BBL X1C"
STANDARD = "0.20mm Standard @BBL X1C"
FINE = "0.12mm Fine @BBL X1C"
# A right click on a point of the cube's top, away from the diagonal its two top triangles share (from the iso
# view the ray to the middle runs along that edge), and one on empty space above the bed.
CUBE_POINT = {"object": 0, "point": [6, -6, 12.8]}
EMPTY = {"x": 1000, "y": 150}
OBJECT = ["Add Part>Cube", "Add Negative Part>Cylinder", "Add Modifier>Cylinder", "Add Support Blocker>Cube",
"Add Support Enforcer>Cube", "Delete", "Printable", "Auto Drop"]
DEFAULT = ["Add Primitive>Cube", "Add Primitive>Cylinder", "Add Primitive>Sphere", "Add Primitive>Cone",
"Add Primitive>Disc", "Add Primitive>Torus", "Add Primitive>Text", "Add Primitive>SVG",
"Add Handy models>Orca Cube", "Add Handy models>OrcaSliced Combo", "Add Handy models>Orca Badge",
"Add Handy models>Orca Tolerance Test", "Add Handy models>3DBenchy", "Add Handy models>Cali Cat",
"Add Handy models>Autodesk FDM Test", "Add Handy models>Voron Cube", "Add Handy models>Stanford Bunny",
"Add Handy models>Orca String Hell", "Add Models", "Show Labels"]
FILAMENT_MENU = ["Edit", "Merge with>Bambu PLA Basic", "Decompose Color", "Delete"]
PLATE_TYPES = ["Smooth Cool Plate", "Engineering Plate", "Smooth High Temp Plate", "Textured PEI Plate",
"Textured Cool Plate", "Cool Plate (SuperTack)"]
COMPARED = '"0.20mm Standard @BBL X1C" vs "0.12mm Fine @BBL X1C"'
LAYER_ROW = "Quality>Layer height>Layer height"
BOTTOM_ROW = "Strength>Top/bottom shells>Bottom shell layers"
ROW = re.compile(r'^(\s*)\[r\d+\] row "(.*)$')
FLAGS = re.compile(r' \[([^\[\]]*)\]$')
PLACE = re.compile(r' @-?\d+,-?\d+ \d+x\d+$')
def O(text, printable=True, plate=0):
"""An object as the entry writes it: 'Cube: Cube part + Generic-Cylinder modifier'."""
return {"object": text, "plate": plate, "printable": printable}
class GuiToolsTest:
def __init__(self, client, folder):
self.c = client
self.t = Checks()
self.folder = folder
# ---- Calls and reads ----
def run(self, tool, **args):
return run(self.c, tool, **args)
def idle(self):
wait(self.c, "idle")
def run_answered(self, tool, **args):
"""Calls `tool` and follows its job to the end through a dialog the start's rules answer, which can hold
the call for a moment (its reply is then blocked_by_dialog); a dialog no rule answers fails the call
after 60 s."""
reply = self.c.await_job(self.c.call(tool, **args), timeout=60)
self.idle()
return reply
def objects(self):
"""Each object as {object: "<name>: <part> <type> + ...", plate, printable}, printable being its first
instance's, in object_list's order; an object outside the plates has plate None."""
listing = self.c.call("object_list", limit=500)
placed = [(p["index"], o) for p in listing["plates"] for o in p["objects"]]
placed += [(None, o) for o in listing.get("outside", [])]
return [{"object": o["name"] + ": " + " + ".join(f"{part['name']} {part['type']}" for part in o["parts"]),
"plate": plate, "printable": o["instances"][0]["printable"]} for plate, o in placed]
def objects_are(self, label, *want):
self.t.equal(f"{label}: the objects", self.objects(), list(want))
def state(self):
return self.c.call("app_state")
def selection(self):
sel = self.state().get("selection") or {}
return {"objects": sel.get("objects", []), "parts": sel.get("parts", [])}
def selection_is(self, label, objects=(), parts=()):
self.t.equal(f"{label}: the selection", self.selection(), {"objects": list(objects), "parts": list(parts)})
@staticmethod
def menu(reply):
popup = (reply or {}).get("popup_menu") or {}
return {k: popup.get(k, []) for k in ("items", "checked", "disabled")}
def dialogs(self):
return [d.get("title") for d in self.state().get("dialogs", [])]
def dialogs_are(self, label, *titles):
self.t.equal(f"{label}: the dialogs open", self.dialogs(), list(titles))
def windows(self):
return [w.get("title") for w in self.c.call("window_list")["items"]]
def window_ref(self, title):
refs = [w["ref"] for w in self.c.call("window_list")["items"] if w.get("title") == title and w.get("ref")]
assert refs, f"no window titled {title}"
return refs[0]
def rows(self, target):
"""The rows widget_list lists under `target` ("main", "dialog", "popup" or a window's title), each as
{path, value, selected, checked}: its labels from the outermost row, joined by ">"; the cells after its
label, joined by " | ", or None; and whether it is selected, and checked (None for a row without a
checkbox)."""
if target not in ("main", "dialog", "popup"):
target = self.window_ref(target)
_, texts = self.c.call_with_text("widget_list", target=target, query="row", max_nodes=2000)
out, stack = [], []
for line in "\n".join(texts).splitlines():
m = ROW.match(line)
if not m:
continue
indent, rest = len(m.group(1)), PLACE.sub("", m.group(2))
flags = []
while (f := FLAGS.search(rest)):
flags = [x.strip() for x in f.group(1).split(",")] + flags
rest = rest[:f.start()]
rest = rest[:-1] if rest.endswith('"') else rest
label, value = rest.rsplit('" = "', 1) if '" = "' in rest else (rest, None)
while stack and stack[-1][0] >= indent:
stack.pop()
stack.append((indent, label))
out.append({"path": ">".join(s[1] for s in stack), "value": value, "selected": "selected" in flags,
"checked": True if "checked" in flags else False if "unchecked" in flags else None})
return out
def listing(self, target="dialog", query=None, **args):
"""widget_list's tree as text."""
if query is not None:
args["query"] = query
_, texts = self.c.call_with_text("widget_list", target=target, **args)
return "\n".join(texts)
def colours(self):
return self.c.call("project_get_settings", keys=["filament_colour"])["items"][0]["value"]
def bed_type(self):
return self.c.call("project_get_settings", keys=["curr_bed_type"])["items"][0]["value"]
def filaments(self):
return self.state()["presets"]["filaments"]
def project_file(self, path):
with zipfile.ZipFile(path) as z:
return json.loads(z.read("Metadata/project_settings.config"))
def canvas_png(self, name):
path = os.path.join(self.folder, name + ".png")
self.c.call("window_screenshot", target="canvas", include_image=False, save_path=path, overwrite=True)
with open(path, "rb") as f:
return f.read()
def process_settings(self, *keys):
items = self.c.call("settings_get", type="process", keys=list(keys))["items"]
return {i["key"]: i["value"] for i in items}
def modified(self, kind):
return [p["name"] for p in self.c.call("preset_list", type=kind, limit=500)["items"] if p.get("modified")]
def job_ends(self, label, job, timeout=60):
"""Follows a job a call left waiting on a dialog to its end; it must end without an error."""
try:
result = self.c.await_job(job, timeout=timeout)
except orca_mcp.McpError as e:
self.t.check(f"{label}: the job ends without an error", False, str(e))
return None
self.t.check(f"{label}: the job ends without an error", result.get("status") not in ("running", "blocked_by_dialog"), result)
return result
def refused_with(self, label, call, words):
"""Checks the call is refused with text holding `words` and returns the refusal's details."""
details = {}
def wrapped():
try:
return call()
except orca_mcp.McpError as e:
details.update(refusal(e)[1])
raise
self.t.refused(label, wrapped, words=words)
return details
def start(self, name):
self.run("project_new", discard_changes=True, preset_changes="discard")
self.run("view_set", tab="prepare")
self.run("dialog_auto_answer", rules=[{"match": "Uniform scale", "button": "ok"},
{"match": "per-object setting mode", "button": "ok"}])
self.idle()
self.dialogs_are(f"{name}: the start")
self.t.equal(f"{name}: the start: the plates", plates(self.c),
[{"name": "", "current": True, "locked": False, "objects": 0}])
def to_one_slot(self):
"""Deletes filament slots until the delete is refused, at the one slot a project keeps."""
for _ in range(32):
try:
self.c.call("filament_delete")
except orca_mcp.McpError:
break
self.idle()
def add_cube(self):
"""The Add Cube action's cube, its size dialog answered by the "Uniform scale" rule."""
self.run_answered("action_run", id=ADD_CUBE)
def objects_switch(self):
"""The sidebar's Global/Objects switch on Objects, which shows the object list."""
self.run("widget_set_value", target={"class": "SwitchButton", "label": "Process"}, value=True)
self.idle()
def filament_button(self):
"""Filament 1's "Click to edit preset" button: the first of that name widget_list shows on screen. The
printer's button of that name is listed first but hidden until the pointer is over its panel."""
for line in self.listing("main", "Click to edit preset").splitlines():
m = re.search(r'\[(w\d+)\] button "Click to edit preset".* @-?\d+,-?\d+ (\d+)x(\d+)$', line)
if m and int(m.group(2)) > 0 and int(m.group(3)) > 0:
return m.group(1)
raise AssertionError("no Click to edit preset button is shown")
# ---- Scenarios ----
def menus(self):
s = "menus"
self.start(s)
self.to_one_slot()
self.add_cube()
self.run("view_set", camera="iso")
cube, with_modifier = "Cube: Cube part", "Cube: Cube part + Generic-Cylinder modifier"
self.objects_are(f"{s}: the start", O(cube))
state = self.state()
self.t.equal(f"{s}: the start: one filament slot", len(state["presets"]["filaments"]), 1)
self.t.equal(f"{s}: the start: labels are off", state["view"]["labels"], False)
# A menu item's job is followed through a dialog the start's rules answer, as run_answered() does.
def C(**args):
return self.c.await_job(self.c.call("mouse_gesture", action="click", button="right", at=CUBE_POINT,
**args), timeout=60)
def E(**args):
return self.c.await_job(self.c.call("mouse_gesture", action="click", button="right", **EMPTY, **args),
timeout=60)
m = self.menu(C())
self.t.check(f"{s} 1: the object menu holds every item it must", set(OBJECT) <= set(m["items"]),
sorted(set(OBJECT) - set(m["items"])))
self.t.check(f"{s} 1: the object menu has no Add Primitive>Cube and no Assemble",
not {"Add Primitive>Cube", "Assemble"} & set(m["items"]), m["items"])
self.t.equal(f"{s} 1: the checked items", m["checked"], ["Printable", "Auto Drop"])
self.dialogs_are(f"{s} 1: listing a menu runs nothing")
self.objects_are(f"{s} 1", O(cube))
reply = C(popup_item="add modifier>cylinder")
self.idle()
self.t.equal(f"{s} 2: the item run, named as the menu shows it", reply.get("ran"), "Add Modifier>Cylinder")
self.objects_are(f"{s} 2", O(with_modifier))
self.run("action_run", id=UNDO)
self.idle()
self.objects_are(f"{s} 3: the menu item's command is one undo step", O(cube))
self.run("action_run", id=REDO)
self.idle()
self.objects_are(f"{s} 4", O(with_modifier))
reply = self.run("widget_click", target={"menu": "Edit>Undo"})
self.idle()
self.t.equal(f"{s} 5: the reply's item", reply.get("clicked"), "Edit>Undo")
self.objects_are(f"{s} 5", O(cube))
reply = self.run("widget_click", target={"menu": "Edit>Redo"})
self.idle()
self.t.equal(f"{s} 6: the reply's item", reply.get("clicked"), "Edit>Redo")
self.objects_are(f"{s} 6", O(with_modifier))
reply = C(popup_item="Printable")
self.idle()
self.t.equal(f"{s} 7: the reply's item", reply.get("ran"), "Printable")
self.objects_are(f"{s} 7", O(with_modifier, printable=False))
self.t.equal(f"{s} 8: the listing reads the check item's state", self.menu(C())["checked"], ["Auto Drop"])
self.objects_are(f"{s} 8", O(with_modifier, printable=False))
C(popup_item="Printable")
self.idle()
self.objects_are(f"{s} 9", O(with_modifier))
details = self.refused_with(f"{s} 10: a submenu is refused", lambda: C(popup_item="Add Modifier"),
'"Add Modifier" is a submenu')
self.t.check(f"{s} 10: the refusal lists the submenu's items",
"Add Modifier>Cylinder" in details.get("items", []), details)
self.objects_are(f"{s} 10", O(with_modifier))
self.t.refused(f"{s} 11: an item the menu lacks is refused", lambda: C(popup_item="Add Modifier>Pyramid"),
words='The menu has no item "Add Modifier>Pyramid"')
self.objects_are(f"{s} 11", O(with_modifier))
self.run("object_select", none=True)
self.selection_is(f"{s} 12: after the select")
self.t.equal(f"{s} 12: the empty space's menu", self.menu(E()), {"items": DEFAULT, "checked": [], "disabled": []})
self.objects_are(f"{s} 12", O(with_modifier))
labels_off = self.canvas_png("labels_off")
E(popup_item="Show Labels")
self.idle()
labels_on = self.canvas_png("labels_on")
self.t.equal(f"{s} 13: labels are on", self.state()["view"]["labels"], True)
self.t.check(f"{s} 13: the 3D view draws the cube's label", labels_on != labels_off, "the captures are the same")
self.objects_are(f"{s} 13", O(with_modifier))
self.t.equal(f"{s} 14: the checked items", self.menu(E())["checked"], ["Show Labels"])
self.objects_are(f"{s} 14", O(with_modifier))
E(popup_item="Show Labels")
self.idle()
labels_off_again = self.canvas_png("labels_off_again")
self.t.equal(f"{s} 15: labels are off", self.state()["view"]["labels"], False)
self.t.check(f"{s} 15: the label is gone again", labels_off_again != labels_on, "the captures are the same")
self.objects_are(f"{s} 15", O(with_modifier))
E(popup_item="Add Primitive>Cylinder")
self.idle()
both = (O(with_modifier), O("Cylinder: Cylinder part"))
self.objects_are(f"{s} 16", *both)
self.t.equal(f"{s} 16: app_state counts the objects", self.state()["objects"], 2)
self.run("widget_click", target={"label": "Add one filament"})
self.idle()
self.t.equal(f"{s} 17: two filament slots", len(self.filaments()), 2)
self.objects_are(f"{s} 17", *both)
self.run("project_set_settings", values={"filament_colour": "#FF0000;#0000FF"})
self.t.equal(f"{s} 18: the colours", self.colours(), "#FF0000;#0000FF")
self.objects_are(f"{s} 18", *both)
button = self.filament_button()
reply = self.c.call("widget_click", target=button)
self.t.equal(f"{s} 19: filament 1's menu", self.menu(reply)["items"], FILAMENT_MENU)
self.dialogs_are(f"{s} 19")
self.t.equal(f"{s} 19: the tab", self.state()["tab"], "prepare")
self.objects_are(f"{s} 19", *both)
reply = self.c.call("widget_click", target=button, popup_item="Delete")
self.idle()
self.t.equal(f"{s} 20: the reply's item", reply.get("ran"), "Delete")
self.t.equal(f"{s} 20: one filament slot", len(self.filaments()), 1)
self.t.equal(f"{s} 20: the slot whose button was clicked is the one deleted", self.colours(), "#0000FF")
self.objects_are(f"{s} 20", *both)
self.run("object_select", all=True)
self.selection_is(f"{s} 21: after the select", objects=[0, 1])
m = self.menu(C())
self.t.check(f"{s} 21: the multi-selection menu holds Assemble, Align left and Delete",
{"Assemble", "Align/Distribute>Align left (-X)", "Delete"} <= set(m["items"]), m["items"])
self.t.check(f"{s} 21: the multi-selection menu has no Add Part>Cube", "Add Part>Cube" not in m["items"],
m["items"])
self.objects_are(f"{s} 21", *both)
reply = C(popup_item="Delete")
self.idle()
self.t.equal(f"{s} 22: the reply's item", reply.get("ran"), "Delete")
self.objects_are(f"{s} 22: the multi-selection's Delete removes both objects")
state = self.state()
self.t.equal(f"{s} 22: app_state counts no objects", state["objects"], 0)
self.t.equal(f"{s} 22: no menu left unseen", state["closed_menus"], [])
self.t.equal(f"{s} 22: no dialog", [d.get("title") for d in state["dialogs"]], [])
def object_rows(self):
s = "object list rows"
self.start(s)
self.add_cube()
self.objects_switch()
cube = "Cube: Cube part"
self.objects_are(f"{s}: the start", O(cube))
paths = [r["path"] for r in self.rows("main")]
self.t.check(f"{s} 1: the rows hold Plate 1 and Cube under it", {"Plate 1", "Plate 1>Cube"} <= set(paths), paths)
self.run("widget_click", target={"gltoolbar": "addplate"})
self.idle()
self.t.equal(f"{s} 2: two plates", len(plates(self.c)), 2)
self.t.equal(f"{s} 2: the current plate", self.state()["plates"]["current"], 1)
for step, row, current in ((3, "Plate 1", 0), (4, "Plate 2", 1), (5, "Plate 1", 0)):
reply = self.run("widget_click", target={"row": row})
self.idle()
if step != 5:
self.t.equal(f"{s} {step}: the reply's selection", reply.get("selected"), [row])
self.t.equal(f"{s} {step}: the current plate", self.state()["plates"]["current"], current)
self.run("object_select", none=True)
self.selection_is(f"{s} 6: after the select")
reply = self.run("widget_click", target={"row": "Cube"})
self.t.equal(f"{s} 6: the reply's selection", reply.get("selected"), ["Plate 1>Cube"])
self.selection_is(f"{s} 6", objects=[0])
self.run("view_set", look_at=[0, 0, 0], zoom=1)
camera = self.state()["camera"]
self.t.near(f"{s} 7: the camera looks at the origin", camera["look_at"], [0, 0, 0], 1e-6)
self.t.near(f"{s} 7: the zoom", camera["zoom"], 1, 1e-6)
reply = self.run("widget_click", target={"row": "Plate 1>Cube"}, double=True)
self.t.equal(f"{s} 8: the reply's selection", reply.get("selected"), ["Plate 1>Cube"])
box = self.c.call("object_list")["plates"][0]["objects"][0]["bbox"]
centre = [(a + b) / 2 for a, b in zip(box["min"], box["max"])]
camera = self.state()["camera"]
self.t.near(f"{s} 8: a double click frames the object", camera["look_at"], centre, 0.01)
self.t.check(f"{s} 8: the double click zooms in", camera["zoom"] > 1, camera["zoom"])
m = self.menu(self.run("widget_click", target={"row": "Cube"}, button="right"))
self.t.check(f"{s} 9: the row's menu is the object's", set(OBJECT) <= set(m["items"]),
sorted(set(OBJECT) - set(m["items"])))
self.t.equal(f"{s} 9: the checked items", m["checked"], ["Printable", "Auto Drop"])
reply = self.run_answered("widget_click", target={"row": "Cube"}, button="right",
popup_item="Add Modifier>Cylinder")
self.t.equal(f"{s} 10: the reply's item", reply.get("ran"), "Add Modifier>Cylinder")
self.objects_are(f"{s} 10", O("Cube: Cube part + Generic-Cylinder modifier"))
reply = self.run("widget_click", target={"row": "Cube>Generic-Cylinder"})
self.t.equal(f"{s} 11: the reply's selection", reply.get("selected"), ["Plate 1>Cube>Generic-Cylinder"])
self.t.equal(f"{s} 11: the parts selected", self.selection()["parts"], [[0, 1]])
reply = self.run("widget_click", target={"row": "Cube>Cube"}, modifiers=["ctrl"])
self.t.equal(f"{s} 12: the reply's selection", reply.get("selected"),
["Plate 1>Cube>Cube", "Plate 1>Cube>Generic-Cylinder"])
self.selection_is(f"{s} 12: both parts select the whole cube", objects=[0])
self.run("widget_click", target={"row": "Cube>Generic-Cylinder"})
self.t.equal(f"{s} 13: the part alone is selected", self.selection()["parts"], [[0, 1]])
reply = self.run_answered("widget_click", target={"row": "Cube>Generic-Cylinder"}, button="right",
popup_item="Change Type>Negative Part")
self.t.equal(f"{s} 14: the reply's item", reply.get("ran"), "Change Type>Negative Part")
negative = "Cube: Cube part + Generic-Cylinder negative"
self.objects_are(f"{s} 14", O(negative))
self.run("widget_click", target={"row": "Plate 1>Cube", "column": "Printable"})
self.idle()
self.objects_are(f"{s} 15", O(negative, printable=False))
reply = self.run("plate_slice")
self.t.equal(f"{s} 16: the slice's outcome", [p.get("outcome") for p in reply.get("plates", [])], ["empty"])
self.t.equal(f"{s} 16: plate 0 is not sliced", self.c.call("plate_list")["items"][0]["sliced"], False)
path = os.path.join(self.folder, "rows.3mf")
self.run("project_save", path=path, overwrite=True)
self.run("project_new", discard_changes=True)
self.idle()
self.objects_are(f"{s} 17: after the new project")
self.run("project_open", path=path)
self.idle()
self.objects_are(f"{s} 17: the project file keeps the part's type and the printable flag",
O(negative, printable=False))
self.run("widget_click", target={"row": "Plate 1>Cube", "column": "Printable"})
self.idle()
self.objects_are(f"{s} 18", O(negative))
reply = self.run("plate_slice")
self.t.equal(f"{s} 19: the slice's outcome", [p.get("outcome") for p in reply.get("plates", [])], ["ok"])
self.t.equal(f"{s} 19: plate 0 is sliced", self.c.call("plate_list")["items"][0]["sliced"], True)
state = self.state()
self.t.equal(f"{s} 20: no dialog and no menu left unseen", (state["dialogs"], state["closed_menus"]), ([], []))
def compare_presets(self):
"""Opens Compare presets, sets its right-hand process preset and clicks the layer height row."""
self.run("widget_click", target={"label": "Compare presets"})
self.idle()
opened = "Compare presets" in self.windows()
self.run("widget_set_value", target={"class": "PresetComboBox", "within": "Compare presets", "index": 5},
value=FINE)
rows = self.rows("Compare presets")
reply = self.run("widget_click", target={"row": LAYER_ROW, "within": "Compare presets"})
return opened, rows, reply
def dialog_rows(self):
s = "dialog rows"
self.start(s)
self.add_cube()
self.objects_switch()
self.run_answered("widget_click", target={"row": "Cube"}, button="right", popup_item="Add Modifier>Cylinder")
with_modifier = O("Cube: Cube part + Generic-Cylinder modifier")
self.objects_are(f"{s}: the start", with_modifier)
self.t.equal(f"{s}: the start: the process preset", self.state()["presets"]["process"], STANDARD)
self.t.equal(f"{s}: the start: the plate type", self.bed_type(), "Cool Plate")
self.t.check(f"{s}: the start: Compare presets is not open", "Compare presets" not in self.windows(),
self.windows())
opened, rows, reply = self.compare_presets()
self.t.check(f"{s} 1: Compare presets opens", opened, self.windows())
self.dialogs_are(f"{s} 1: Compare presets is modeless")
by_path = {r["path"]: r for r in rows}
self.t.check(f"{s} 2: the header row compares the two presets", COMPARED in by_path, list(by_path))
self.t.equal(f"{s} 2: the layer height row holds both presets' values",
by_path.get(f"{COMPARED}>{LAYER_ROW}", {}).get("value"), "0.2 | 0.12")
self.t.check(f"{s} 3: the reply names the row", LAYER_ROW in str(reply.get("clicked")), reply)
selected = [r["path"] for r in self.rows("Compare presets") if r["selected"]]
self.t.equal(f"{s} 3: the row is selected", selected, [f"{COMPARED}>{LAYER_ROW}"])
self.run("keyboard_press", target={"class": "DiffPresetDialog"}, keys="Escape")
self.idle()
self.t.check(f"{s} 4: Escape closes Compare presets", "Compare presets" not in self.windows(), self.windows())
self.t.equal(f"{s} 4: the process preset", self.state()["presets"]["process"], STANDARD)
self.t.equal(f"{s} 4: comparing changed no process preset", self.modified("process"), [])
self.compare_presets()
transfer = {"label": "Transfer values from left to right", "within": "Compare presets"}
self.run("widget_set_value", target=transfer, value=True)
options = [r for r in self.rows("Compare presets") if r["value"] is not None]
self.t.check(f"{s} 5: every option row starts checked", options and all(r["checked"] for r in options),
[(r["path"], r["checked"]) for r in options])
for r in options:
if r["checked"]:
row = r["path"].split(">", 1)[1]
self.run("widget_set_value", target={"row": row, "within": "Compare presets"}, value=False)
self.run("widget_set_value", target={"row": LAYER_ROW, "within": "Compare presets"}, value=True)
options = {r["path"].split(">", 1)[1]: r["checked"] for r in self.rows("Compare presets")
if r["value"] is not None}
self.t.equal(f"{s} 5: the layer height row alone is checked", [p for p, c in options.items() if c], [LAYER_ROW])
self.t.equal(f"{s} 5: the bottom shell layers row is unchecked", options.get(BOTTOM_ROW), False)
self.run("widget_click", target={"label": "Transfer", "within": "Compare presets"})
self.idle()
self.t.check(f"{s} 6: Transfer closes Compare presets", "Compare presets" not in self.windows(), self.windows())
self.t.equal(f"{s} 6: the process preset", self.state()["presets"]["process"], FINE)
self.t.equal(f"{s} 6: the right-hand preset is modified", self.modified("process"), [FINE])
self.t.equal(f"{s} 6: only the checked row was transferred",
self.process_settings("layer_height", "bottom_shell_layers"),
{"layer_height": "0.2", "bottom_shell_layers": "5"})
self.run("object_select", objects=[0])
self.selection_is(f"{s} 7: after the select", objects=[0])
job = self.c.call("widget_click", target={"row": "Plate 1>Cube"}, button="right",
popup_item="Edit in Parameter Table")
self.t.equal(f"{s} 7: the click waits on the dialog it opens", job.get("status"), "blocked_by_dialog")
self.dialogs_are(f"{s} 7", "Object/Part Settings")
self.t.equal(f"{s} 8: the table's rows", [r["path"] for r in self.rows("dialog")],
["Cube", "Cube", "Generic-Cylinder"])
reply = self.c.call("widget_click", target={"row": "Generic-Cylinder", "within": "Object/Part Settings",
"column": "Wall loops"})
self.t.equal(f"{s} 9: the reply's column", reply.get("column"), "Wall loops")
self.t.equal(f"{s} 9: a cell's click selects its part", self.selection()["parts"], [[0, 1]])
reply = self.c.call("dialog_answer", dialog={"title": "Object/Part Settings"}, button="close")
self.t.equal(f"{s} 10: the reply says the dialog closed", reply.get("closed"), True)
self.job_ends(f"{s} 10: the step 7 click", job)
self.dialogs_are(f"{s} 10")
self.run("widget_click", target={"class": "SideButton", "index": 3})
found = self.c.call("widget_list", target="popup", query="Export plate sliced file")
self.t.equal(f"{s} 11: the print button's popup lists the mode once", found.get("nodes"), 1)
self.run("widget_click", target={"class": "SideButton", "label": "Export plate sliced file"})
self.idle()
self.t.equal(f"{s} 12: the popup is gone", self.c.call("widget_list", target="popup").get("nodes"), 0)
found = self.c.call("widget_list", target="main", query="Export plate sliced file", include_menus=False)
self.t.equal(f"{s} 12: the print button shows the mode picked", found.get("nodes"), 1)
self.dialogs_are(f"{s} 12")
self.run("widget_click", target={"class": "ComboBox", "label": "Smooth Cool Plate"})
self.t.equal(f"{s} 13: the drop-down list's rows", [r["path"] for r in self.rows("popup")], PLATE_TYPES)
reply = self.run("widget_click", target={"row": "Textured PEI Plate"})
self.idle()
self.t.equal(f"{s} 14: the reply's row", reply.get("clicked"), "Textured PEI Plate")
self.t.equal(f"{s} 14: the project's plate type", self.bed_type(), "Textured PEI Plate")
self.t.equal(f"{s} 14: plate 0's plate type", self.c.call("plate_list")["items"][0]["curr_bed_type"],
"Textured PEI Plate")
path = os.path.join(self.folder, "plate_type.3mf")
self.run("project_save", path=path, overwrite=True)
self.t.equal(f"{s} 15: the project file keeps the pick", self.project_file(path).get("curr_bed_type"),
"Textured PEI Plate")
self.run("widget_set_value", target={"class": "ComboBox", "label": "Textured PEI Plate"},
value="Smooth Cool Plate")
self.idle()
self.t.equal(f"{s} 16: the project's plate type", self.bed_type(), "Cool Plate")
state = self.state()
self.t.equal(f"{s} 17: no dialog and no menu left unseen", (state["dialogs"], state["closed_menus"]), ([], []))
def hex_field(self):
"""The hex digits the colour picker's hex field lists."""
for line in self.listing("dialog", "Hex color").splitlines():
m = re.search(r'= "([0-9A-Fa-f]*)"', line)
if m:
return m.group(1)
return None
def pick_colour(self, label):
"""Steps 3, 4, 7 and 8 of the web dialogs: opens the filament picker of slot 1's colour, then its colour
picker, sets the hex field to 3366CC and presses OK; returns the filament picker's job."""
swatch = self.c.call("widget_click", target={"label": "1", "class": "wxBitmapButton"})
more = self.c.call("widget_click", target={"label": "+ More Colors", "within": "Select Filament"})
self.t.equal(f"{label}: the picker on top", self.dialogs(), ["Select Filament", "Color Picker"])
self.t.equal(f"{label}: the hex field's value",
self.c.call("widget_set_value", target=HEX, value="3366CC").get("value"), "3366CCFF")
reply = self.c.call("widget_click", target={"web": "OK", "within": "Color Picker"})
self.t.equal(f"{label}: the picker closes", reply.get("closed"), True)
self.job_ends(f"{label}: the More Colors click", more)
return swatch
def web_dialogs(self):
s = "web dialogs"
self.start(s)
self.to_one_slot()
if self.filaments() != [PLA]:
self.run("preset_select", type="filament", name=PLA, filament_slot=1)
self.run("project_set_settings", values={"filament_colour": "#26A69A"})
self.t.equal(f"{s}: the start: the filaments", self.filaments(), [PLA])
self.t.equal(f"{s}: the start: the colour", self.colours(), "#26A69A")
self.t.equal(f"{s}: the start: no region", self.region(), "")
printers = [(p["name"], bool(p.get("selected"))) for p in self.c.call("preset_list", type="printer")["items"]]
self.t.equal(f"{s}: the start: the printers", printers, [(PRINTER, True)])
job = self.c.call("action_run", id=PRESET_BUNDLE)
self.t.equal(f"{s} 1: the action waits on its dialog", job.get("status"), "blocked_by_dialog")
self.dialogs_are(f"{s} 1", "Preset Bundle")
page = self.listing("dialog")
for name in ("name=#refresh_btn", "name=#close_btn", 'label "Version"', 'label "Update"'):
self.t.check(f"{s} 1: the page lists {name}", name in page, page)
reply = self.c.call("widget_click", target={"css": "#close_btn", "within": "Preset Bundle"})
self.t.equal(f"{s} 2: the page's Close closes the dialog", reply.get("closed"), True)
self.job_ends(f"{s} 2: the step 1 action", job)
self.dialogs_are(f"{s} 2")
swatch = self.c.call("widget_click", target={"label": "1", "class": "wxBitmapButton"})
self.t.equal(f"{s} 3: the swatch waits on its dialog", swatch.get("status"), "blocked_by_dialog")
self.dialogs_are(f"{s} 3", "Select Filament")
self.t.check(f"{s} 3: the dialog lists the slot's colour", "#26A69A" in self.listing("dialog"),
self.listing("dialog"))
more = self.c.call("widget_click", target={"label": "+ More Colors", "within": "Select Filament"})
self.t.equal(f"{s} 4: More Colors waits on its dialog", more.get("status"), "blocked_by_dialog")
self.dialogs_are(f"{s} 4: the picker on top", "Select Filament", "Color Picker")
reply = self.c.call("widget_set_value", target=HEX, value="FF0000")
self.t.equal(f"{s} 5: the reply's value", reply.get("value"), "FF0000FF")
self.t.equal(f"{s} 5: the hex field", self.hex_field(), "FF0000FF")
reply = self.c.call("mouse_gesture", target={"css": "#spectrum", "within": "Color Picker"}, action="drag",
x=20, y=20, to=[200, 100], steps=6)
self.t.equal(f"{s} 6: the reply's gesture", reply.get("done"), "drag")
picked = self.hex_field()
self.t.check(f"{s} 6: the drag picked another colour",
bool(picked and re.fullmatch(r"[0-9A-Fa-f]{8}", picked) and picked.upper() != "FF0000FF"), picked)
reply = self.c.call("widget_set_value", target=HEX, value="3366CC")
self.t.equal(f"{s} 7: the reply's value", reply.get("value"), "3366CCFF")
self.t.equal(f"{s} 7: the hex field", self.hex_field(), "3366CCFF")
reply = self.c.call("widget_click", target={"web": "OK", "within": "Color Picker"})
self.t.equal(f"{s} 8: the picker closes", reply.get("closed"), True)
self.t.equal(f"{s} 8: the dialog under it", [d.get("title") for d in reply.get("dialogs", [])],
["Select Filament"])
self.job_ends(f"{s} 8: the step 4 click", more)
page = self.listing("dialog")
self.t.check(f"{s} 8: the dialog lists the picked colour and not the old one",
"#3366CC" in page and "#26A69A" not in page, page)
self.c.call("dialog_answer", dialog={"title": "Select Filament"}, button="cancel")
self.job_ends(f"{s} 9: the step 3 click", swatch)
self.dialogs_are(f"{s} 9")
self.t.equal(f"{s} 9: a cancelled pick changes nothing", self.colours(), "#26A69A")
swatch = self.pick_colour(f"{s} 10")
self.c.call("dialog_answer", dialog={"title": "Select Filament"}, button="ok")
self.job_ends(f"{s} 10: the swatch's click", swatch)
self.dialogs_are(f"{s} 10")
self.t.equal(f"{s} 10: the colour the picker returned is slot 1's", self.colours(), "#3366CC")
path = os.path.join(self.folder, "colour.3mf")
self.run("project_save", path=path, overwrite=True)
self.t.equal(f"{s} 11: the project file keeps the colour", self.project_file(path).get("filament_colour"),
["#3366CC"])
job = self.c.call("action_run", id=SETUP_WIZARD)
self.t.equal(f"{s} 12: the action waits on its dialog", job.get("status"), "blocked_by_dialog")
self.dialogs_are(f"{s} 12", "Setup Wizard")
self.t.check(f"{s} 12: the page lists Europe within 30 s", self.page_lists('"Europe"', 30), "")
reply = self.c.call("widget_click", target={"web": "Europe", **WIZARD})
self.t.equal(f"{s} 13: the reply's check", reply.get("checked"), True)
self.t.check(f"{s} 13: the wizard lists Europe checked", self.web_checked("Europe"),
self.listing("dialog", "Europe"))
self.c.call("widget_click", target={"web": "Next", **WIZARD})
card = "Nozzle 0.4 Marlin"
reply = self.c.call("widget_click", target={"web": card, "kind": "button", **WIZARD})
self.t.equal(f"{s} 15: the reply's check", reply.get("checked"), True)
self.t.check(f"{s} 15: the wizard lists the card checked", self.web_checked(card),
self.listing("dialog", card))
reply = self.c.call("dialog_answer", dialog={"title": "Setup Wizard"}, button="close")
self.t.equal(f"{s} 16: the reply says the wizard closed", reply.get("closed"), True)
self.job_ends(f"{s} 16: the step 12 action", job)
self.dialogs_are(f"{s} 16")
self.t.equal(f"{s} 16: closing the wizard keeps no region",
self.region(), "")
printers = [(p["name"], bool(p.get("selected"))) for p in self.c.call("preset_list", type="printer")["items"]]
self.t.equal(f"{s} 16: closing the wizard keeps the printers", printers, [(PRINTER, True)])
def page_lists(self, text, timeout_s):
"""Whether the topmost dialog's page lists `text` within `timeout_s`, listed again each half second."""
deadline = time.monotonic() + timeout_s
while True:
if text in self.listing("dialog"):
return True
if time.monotonic() > deadline:
return False
time.sleep(0.5)
def web_checked(self, label):
"""Whether the topmost dialog's page lists an element whose label holds `label` as checked."""
return any(label in line and "[checked]" in line for line in self.listing("dialog", label).splitlines())
def region(self):
return self.c.call("preferences_get", keys=["region"])["items"][0]["value"]
def run_all(self, only=None):
self.run("window_set", size=[1600, 900])
for name, scenario in [("menus", self.menus), ("object list rows", self.object_rows),
("dialog rows", self.dialog_rows), ("web dialogs", self.web_dialogs)]:
if not only or name in only:
self.t.scenario(name, scenario)
self.c.call("dialog_auto_answer", rules=[])
self.run("project_new", discard_changes=True, preset_changes="discard")
return self.t.exit_code()
HEX = {"web": "Hex color", "within": "Color Picker"}
WIZARD = {"within": "Setup Wizard"}
def main():
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("--out", help="folder for the pictures and project files (default: a new temporary folder)")
ap.add_argument("--only", action="append", help="run only this scenario (repeatable)")
args = ap.parse_args()
folder = args.out or tempfile.mkdtemp(prefix="orca-gui-tools-")
os.makedirs(folder, exist_ok=True)
print(f"output folder: {folder}", flush=True)
client, _ = orca_mcp.session_client()
return GuiToolsTest(client, folder).run_all(args.only)
if __name__ == "__main__":
sys.exit(main())
+5 -1
View File
@@ -204,7 +204,11 @@ def defaults_given_back(orca):
installed = set(filaments(orca, include_incompatible=True))
check("the reply names the default filaments the app gives the second printer again, and only those",
given and given == now - in_slots and given <= installed, (removed, sorted(now)))
check("what the reply calls uninstalled is no longer installed", not set(removed.get("uninstalled", [])) & installed, removed)
# filament_uninstall lists under uninstalled only the presets left uninstalled: those asked that the app did not
# give back.
uninstalled = removed.get("uninstalled")
check("what the reply calls uninstalled is exactly what stays uninstalled",
uninstalled is not None and set(uninstalled) == fits - given and not set(uninstalled) & installed, removed)
return velo, sorted(now)
+20 -15
View File
@@ -12,8 +12,8 @@ nozzle of each model it shows ticked, so the test installs the X1 Carbon's other
changes carried over (preset_changes transfer, a process change and the printer's own), which makes the set the dialog
collects the set installed; it then ticks the Velo+, which printer_uninstall took out, clicking its block in the page as a
person does, confirms, and reads every Velo+ nozzle installed and the X1 Carbon's kept. Last, with Generic ABS @System installed, it
installs a model of a third vendor (the Voxelab Aquila X2) and reads the filaments its reload changed in the reply and in
preset_list.
installs a model of a third vendor (the Voxelab Aquila X2) and reads the filaments its reload installed in the reply and
in preset_list, and that it swapped none.
Run it as python tools/mcp/test_install_printers.py [--bin PATH] [--datadir PATH].
"""
import contextlib
@@ -144,6 +144,7 @@ def first_run(orca, datadir):
check("and nothing was installed", preset_of(orca, VELO["model"], "0.4") is None)
before, _ = printers(orca)
filaments_before = installed_filaments(orca)
installed = call(orca, "printer_install", models=[dict(VELO, nozzles=["0.4"])])
print(f"printer_install: {installed}", flush=True)
velo_preset = preset_of(orca, VELO["model"], "0.4")
@@ -155,12 +156,16 @@ def first_run(orca, datadir):
preset_of(orca, VELO["model"], "0.2") is None and set(before) <= set(names), names)
velo = model(orca, "Goofoo", VELO["model"])
check("printer_list_models marks its 0.4 nozzle installed", velo is not None and velo["installed_nozzles"] == ["0.4"], velo)
# The reload installs a printer's default filaments where no installed one fits it: the reply names them, and the
# selectors offer them.
# The reload installs a printer's default filaments where no installed one fits it (load_installed_filaments()), and
# none of the X1 Carbon's filaments the folder holds fits the Velo+: the reply names the Velo+ model's
# default_materials, Goofoo ABS @System, which preset_list then lists installed, and the selectors offer them.
reported = installed.get("filaments_installed", [])
gained = installed_filaments(orca) - filaments_before
check("the reload installs the Velo+'s default filament",
reported != [] and set(reported) == gained and "Goofoo ABS @System" in reported
and "filaments_uninstalled" not in installed, (installed, sorted(gained)))
offered = {item["name"] for item in orca.call("preset_list", type="filament", printer=velo_preset, limit=500)["items"]}
check("the filaments the reload installed are named and offered for it",
set(installed.get("filaments_installed", [])) <= offered and installed.get("filaments_uninstalled") is None,
(installed.get("filaments_installed"), sorted(offered)))
check("and offers them for it", reported != [] and set(reported) <= offered, (reported, sorted(offered)))
return velo_preset
@@ -229,19 +234,19 @@ def second_run(orca, velo_preset):
x1c_after == x1c_before and set(names_before) <= set(names_after), (x1c_before, x1c_after))
check("and selects a printer the Confirm added", selected_after in velo_presets, selected_after)
# The filaments the reload of a printer install changes, with a @System filament installed, which the reload swaps for
# its vendor's own where a vendor's profile names one: the reply and preset_list agree.
# The filaments the reload of a third vendor's printer install changes, with a @System filament installed. A reload
# swaps a @System filament only for a vendor whose bundle lists default filaments of its own (its default_filaments,
# which PresetBundle::apply_vendor_config() reads); only an INI bundle fills that list and the shipped JSON profiles
# never do, so the install swaps none.
orca.call("filament_install", names=["Generic ABS @System"])
before = installed_filaments(orca)
voxelab = call(orca, "printer_install", models=[{"vendor": "Voxelab", "model": "Voxelab Aquila X2"}])
after = installed_filaments(orca)
print(f"printer_install of another vendor's model: {voxelab}", flush=True)
check("printer_install's filaments_installed and filaments_uninstalled are what preset_list shows changed",
set(voxelab.get("filaments_installed", [])) == after - before
and set(voxelab.get("filaments_uninstalled", [])) == before - after, (voxelab, sorted(after ^ before)))
check("and Generic ABS @System is reported uninstalled exactly when preset_list no longer has it installed",
("Generic ABS @System" in voxelab.get("filaments_uninstalled", [])) == ("Generic ABS @System" not in after),
(voxelab, "Generic ABS @System" in after))
check("printer_install's filaments_installed is what preset_list shows installed",
set(voxelab.get("filaments_installed", [])) == after - before, (voxelab, sorted(after - before)))
check("and swaps no filament", "filaments_uninstalled" not in voxelab and before <= after and "Generic ABS @System" in after,
(voxelab, sorted(before - after)))
def installed_filaments(orca):
+51
View File
@@ -53,6 +53,7 @@ A refusal is an error a replay cannot expect, which is why this is a script. Exi
import json
import os
import re
import sys
import time
@@ -117,6 +118,52 @@ def main():
return rule.get("uses", 0)
return None
def close_notice(words):
"""Closes the notice whose text holds `words`, as a click on its close button does, so that a later pick that
shows the same text is seen to show it: the same text pushed again only moves the open notice to the end of the
list (NotificationManager::activate_existing()). Then checks that app_state.notifications holds no notice with
that text, waiting up to 5 s.
widget_list lists each notification as the ImGui window "!!Ntfctn<id>" with its lines as text nodes. Its close
glyph and the large invisible button over it, " ", have labels the listing cleans to nothing and no ## name, so
neither has a ref; the locator {imgui: "", window: ...} matches the window's unlabelled items in the order they
are recorded, and render_close_button() submits the invisible button last. A notice that has already faded (a
regular notice fades about 10 s after it shows) leaves nothing to close."""
_, texts = client.call_with_text("widget_list", include_menus=False, include_web=False)
lines, window = {}, None
for line in "\n".join(texts).splitlines():
header = re.match(r'\s*\[-\] imgui_window "(!!Ntfctn\d+)"', line)
text = re.match(r'\s*\[-\] text "(.*)" @', line)
if header:
window = header.group(1)
lines[window] = []
elif text and window is not None:
lines[window].append(text.group(1))
else:
window = None
clicked = []
for window in [w for w, held in lines.items() if words in " ".join(held)]:
locator = {"imgui": "", "window": window}
try:
client.call("widget_click", target=locator)
clicked.append((window, "the one unlabelled item"))
except orca_mcp.McpError as e:
count = re.match(r"(\d+) ImGui items match", str(e))
try:
if count is None:
raise e
client.call("widget_click", target=dict(locator, index=int(count.group(1)) - 1))
clicked.append((window, f"item {count.group(1)} of {count.group(1)}"))
except orca_mcp.McpError as failed:
clicked.append((window, str(failed)))
deadline = time.monotonic() + 5
while any(words in text for text in notices(client.call("app_state"))):
if time.monotonic() > deadline:
check("the earlier notice is closed", False, (clicked, notices(client.call("app_state"))))
return
time.sleep(0.2)
check("the earlier notice is closed", True)
client.call("app_wait", **{"for": "ready"})
client.call("project_new", discard_changes=True, preset_changes="discard")
client.call("view_set", tab="prepare")
@@ -418,6 +465,8 @@ def main():
client.call("project_new", discard_changes=True)
cube("left", part="part")
cube("right", part="part")
# Assemble with one object selected, above, showed the same text.
close_notice("Select two or more objects first")
list_rows("left>left", "left>Generic-Cube")
dial_pick("Assemble")
state = settled()
@@ -454,6 +503,8 @@ def main():
check("and splits nothing", total() == 1, total())
client.call("project_new", discard_changes=True)
cube("parts", part="part")
# Split to Objects on two instance rows, above, showed the same text.
close_notice("one object or part at a time")
list_rows("parts>parts", "parts>Generic-Cube")
dial_pick("Split to Parts")
state = settled()
+757
View File
@@ -0,0 +1,757 @@
#!/usr/bin/env python3
"""What objects are made of and how the list orders them, as the test_object_structure entry of
tools/mcp/test-entries/objects.md designs it.
tools/mcp/orca_mcp.py launch
tools/mcp/test_object_structure.py
Renaming and deleting objects, and the layer commands acting on the selected object; Split to Objects and to Parts,
and Assemble; adding parts of every type, changing a part's type and renaming a part; ordering a plate's objects and
the print order that sets; Fix Model by index and through the object's menu; Reload from disk and Replace 3D file;
and the keep_painting preference, shown against its control. After every step the test reads the objects back with
object_list and compares their names, and the parts' types where the entry writes them, with the state the entry
writes out. It runs on the harness's default printer, the Bambu Lab X1 Carbon 0.4, and exits 0 when every check
passes.
"""
import os
import re
import shutil
import sys
import tempfile
import time
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import orca_mcp # noqa: E402
from checks import Checks, corner, gcode_prints, plates, run, scene, selection, wait # noqa: E402
REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
FIXTURES = os.path.join(REPO, "tools", "mcp", "tests", "fixtures")
# The system's own form of the path, as the loader names the object after its last separator.
RINGS = os.path.normpath(os.path.join(REPO, "tests", "data", "two_hollow_squares.obj"))
DRC = os.path.join(REPO, "resources", "handy_models", "OrcaCube_v2.drc")
STAR = os.path.join(FIXTURES, "star.svg")
HEIGHTMAP = os.path.join(FIXTURES, "heightmap.png")
ROW = re.compile(r'^"(.*)" (\d+)( \*)?$')
CUBE = {"shape": "cube", "size": [20, 20, 20]}
RING = [10.67, 10.67, 2.8]
RINGS_SIZE = [68.67, 10.67, 2.8]
# The endings of Fix Model's notices (the object list's fix_through_cgal()).
REPAIR_ENDINGS = ("has been repaired", "have been repaired", "needed no repair", "Failed to repair",
"Repairing was canceled")
# A cube of side 1 from the origin: its corners and its twelve triangles, each turned outward; the last is the one
# holed.stl lacks, and the two top ones (4, 5, 6) and (4, 6, 7) are the ones top4.stl splits into four.
CORNERS = [(0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0), (0, 0, 1), (1, 0, 1), (1, 1, 1), (0, 1, 1)]
TRIANGLES = [(0, 2, 1), (0, 3, 2), (4, 5, 6), (4, 6, 7), (0, 1, 5), (0, 5, 4),
(1, 2, 6), (1, 6, 5), (2, 3, 7), (2, 7, 6), (3, 0, 4), (3, 4, 7)]
def cube_triangles(size, holed=False, top4=False):
"""The triangles of a cube of `size` mm from the origin: without the last one when `holed`, with its top as four
triangles about the top's centre when `top4`."""
points = [tuple(c * size for c in corner_) for corner_ in CORNERS]
triangles = [tuple(points[i] for i in t) for t in TRIANGLES]
if holed:
triangles = triangles[:-1]
if top4:
centre = (size / 2, size / 2, size)
triangles = [t for i, t in enumerate(triangles) if i not in (2, 3)]
triangles += [(points[a], points[b], centre) for a, b in ((4, 5), (5, 6), (6, 7), (7, 4))]
return triangles
def write_stl(path, triangles):
"""An ASCII STL of the triangles."""
lines = ["solid cube"]
for triangle in triangles:
lines += [" facet normal 0 0 0", " outer loop"]
lines += [" vertex %g %g %g" % vertex for vertex in triangle]
lines += [" endloop", " endfacet"]
lines.append("endsolid cube")
with open(path, "w") as f:
f.write("\n".join(lines) + "\n")
def P(*rows):
"""Plates written as the entry writes them: '"" 3 *' is an unnamed current plate with three objects."""
out = []
for row in rows:
m = ROW.match(row)
assert m, row
out.append({"name": m.group(1), "current": bool(m.group(3)), "locked": False, "objects": int(m.group(2))})
return out
def centre(box):
return [(lo + hi) / 2 for lo, hi in zip(box["min"], box["max"])]
def names(objects):
"""The objects' names in index order, from scene()."""
return [o["name"] for o in objects]
def types(obj):
"""An object's parts' types in order, from its entry in scene()."""
return [p["type"] for p in obj["parts"]]
def names_of(reply_items):
"""The `index` and `name` of each object a reply names."""
return [{"index": o.get("index"), "name": o.get("name")} for o in reply_items or []]
class ObjectStructureTest:
def __init__(self, client, folder):
self.c = client
self.t = Checks()
self.W = folder
for name, triangles in (("cube20.stl", cube_triangles(20)), ("cube30.stl", cube_triangles(30)),
("holed.stl", cube_triangles(20, holed=True)),
("top4.stl", cube_triangles(20, top4=True))):
write_stl(self.file(name), triangles)
# ---- Calls and reads ----
def file(self, name):
return os.path.join(self.W, name)
def run(self, tool, **args):
return run(self.c, tool, **args)
def undo(self):
self.run("undo", history="project")
def redo(self):
self.run("redo", history="project")
def notices(self):
return [n.get("text", "") for n in self.c.call("app_state").get("notifications", [])]
def dialogs(self):
return [d.get("title") for d in self.c.call("app_state").get("dialogs", [])]
def gizmo(self):
return self.c.call("app_state").get("gizmo")
def plates_are(self, label, *rows):
self.t.equal(f"{label}: the plates", plates(self.c), P(*rows))
def objects_are(self, label, *rows, plate_rows=None):
"""The objects' names in index order compared with the rows whole, and the parts' types of every object a row
writes them for ("Assembly: part, modifier"); then the plates, '"" n *' unless `plate_rows` gives them.
Returns scene()."""
objects = scene(self.c)
self.t.equal(f"{label}: the objects", names(objects), [row.split(": ")[0] for row in rows])
for i, row in enumerate(rows):
if ": " in row:
got = types(objects[i]) if i < len(objects) else None
self.t.equal(f"{label}: object {i}'s parts", got, row.split(": ", 1)[1].split(", "))
self.plates_are(label, *(plate_rows or [f'"" {len(rows)} *']))
return objects
def start(self, name):
self.run("project_new", discard_changes=True)
self.run("view_set", tab="prepare")
wait(self.c, "idle")
self.empty(f"{name}: the start")
self.c0 = corner(self.c, 0)
def empty(self, label):
self.plates_are(label, '"" 0 *')
self.t.equal(f"{label}: no objects", scene(self.c), [])
def at(self, x, y, z=None):
"""A place given from plate 0's corner, in the app's coordinates."""
return [self.c0[0] + x, self.c0[1] + y] + ([] if z is None else [z])
def placed(self, label, obj, x, y):
"""The object's instance 0 at +(x, y) from plate 0's corner."""
self.t.near(f"{label}: {obj['name']} at +({x}, {y})", obj["instances"][0]["offset"][:2], self.at(x, y), 0.001)
def part_placed(self, label, obj, part, x, y, z, tolerance=0.001):
self.t.near(f"{label}: part {part} of {obj['name']} at +({x}, {y}, {z})", obj["parts"][part]["position"],
self.at(x, y, z), tolerance)
def rings(self, label, boxes):
"""Two boxes, each a ring's, standing side by side: their centres 58 mm apart along x and level along y."""
for i, box in enumerate(boxes):
self.t.near(f"{label}: ring {i + 1}'s box", box["size"], RING, 0.01)
a, b = sorted((centre(box) for box in boxes), key=lambda c: c[0])
self.t.near(f"{label}: the rings side by side", [b[0] - a[0], b[1] - a[1]], [58, 0], 0.01)
# ---- Scenarios ----
def renaming(self):
s = "renaming and deleting"
self.start(s)
for x in (40, 100, 160):
self.run("object_add_primitive", position=self.at(x, 60, 0), **CUBE)
self.run("object_select", none=True)
objects = self.objects_are(f"{s} 1", "Cube", "Cube", "Cube")
for obj, x in zip(objects, (40, 100, 160)):
self.placed(f"{s} 1", obj, x, 60)
reply = self.run("object_rename", object=1, name="middle")
self.t.equal(f"{s} 2: the reply", names_of(reply.get("objects")), [{"index": 1, "name": "middle"}])
self.objects_are(f"{s} 2", "Cube", "middle", "Cube")
reply = self.run("object_delete", objects=[0])
self.t.equal(f"{s} 3: the reply's objects", names_of(reply.get("objects")), [{"index": 0, "name": "Cube"}])
self.t.equal(f"{s} 3: the reply's object_count", reply.get("object_count"), 2)
objects = self.objects_are(f"{s} 3", "middle", "Cube")
self.placed(f"{s} 3", objects[0], 100, 60)
self.placed(f"{s} 3", objects[1], 160, 60)
self.undo()
self.objects_are(f"{s} 4: the delete was one undo step", "Cube", "middle", "Cube")
self.redo()
self.objects_are(f"{s} 5", "middle", "Cube")
self.run("object_select", objects=[0])
reply = self.run("object_delete")
self.t.equal(f"{s} 6: the reply's objects", names_of(reply.get("objects")), [{"index": 0, "name": "middle"}])
self.t.equal(f"{s} 6: the reply's object_count", reply.get("object_count"), 1)
objects = self.objects_are(f"{s} 6", "Cube")
self.placed(f"{s} 6", objects[0], 160, 60)
self.t.refused(f"{s} 7: a name with a slash is refused", lambda: self.c.call("object_rename", object=0,
name="a/b"), code="invalid_name")
self.t.refused(f"{s} 7: an empty name is refused", lambda: self.c.call("object_rename", object=0, name=""),
code="empty_name")
self.objects_are(f"{s} 7", "Cube")
self.run("object_add_primitive", name="layered", position=self.at(60, 160, 0), **CUBE)
self.run("object_select", objects=[1])
reply = self.run("object_set_height_ranges", ranges=[{"min_z": 0, "max_z": 5}])
self.t.equal(f"{s} 8: the reply's object", reply.get("object"), 1)
self.t.equal(f"{s} 8: the reply's objects", names_of(reply.get("objects")), [{"index": 1, "name": "layered"}])
self.t.equal(f"{s} 8: the reply's range", [{k: r.get(k) for k in ("min_z", "max_z")}
for r in reply.get("layer_config_ranges", [])],
[{"min_z": 0, "max_z": 5}])
objects = self.objects_are(f"{s} 8", "Cube", "layered")
self.t.equal(f"{s} 8: layered has the range", [{k: r.get(k) for k in ("min_z", "max_z")}
for r in objects[1].get("layer_config_ranges", [])],
[{"min_z": 0, "max_z": 5}])
self.t.check(f"{s} 8: Cube has no range", "layer_config_ranges" not in objects[0], objects[0])
reply = self.run("object_set_variable_layer_height", action="adaptive")
self.t.equal(f"{s} 9: the reply's object", reply.get("object"), 1)
self.t.equal(f"{s} 9: the reply's objects", names_of(reply.get("objects")),
[{"index": 1, "name": "layered"}])
self.t.check(f"{s} 9: the reply has a layer_height_profile", "layer_height_profile" in reply, reply)
objects = self.objects_are(f"{s} 9", "Cube", "layered")
points = (objects[1].get("layer_height_profile") or {}).get("points")
self.t.check(f"{s} 9: layered has a profile with points", isinstance(points, int) and points > 0,
objects[1].get("layer_height_profile"))
self.t.check(f"{s} 9: Cube has no profile", "layer_height_profile" not in objects[0], objects[0])
def splitting(self):
s = "splitting and assembling"
self.start(s)
name = "two_hollow_squares.obj"
reply = self.run("project_import", paths=[RINGS])
self.t.equal(f"{s} 1: the import's added", reply.get("added"), 1)
objects = self.objects_are(f"{s} 1", f"{name}: part")
self.t.near(f"{s} 1: its box", objects[0]["bbox"]["size"], RINGS_SIZE, 0.01)
reply = self.run("object_split", object=0, into="objects")
self.t.equal(f"{s} 2: the reply's objects", [o.get("index") for o in reply.get("objects", [])], [0, 1])
self.t.equal(f"{s} 2: the reply's object_count", reply.get("object_count"), 2)
objects = self.objects_are(f"{s} 2", f"{name}_1: part", f"{name}_2: part")
self.rings(f"{s} 2", [o["bbox"] for o in objects])
self.t.equal(f"{s} 2: the pieces are selected", selection(self.c)["objects"], [0, 1])
self.t.equal(f"{s} 3: the import's added", self.run("project_import", paths=[RINGS]).get("added"), 1)
reply = self.run("object_split", object=2, into="parts")
self.t.equal(f"{s} 3: the reply's parts", [{k: p.get(k) for k in ("object", "part")}
for p in reply.get("parts", [])],
[{"object": 2, "part": 0}, {"object": 2, "part": 1}])
self.t.equal(f"{s} 3: the reply's object_count", reply.get("object_count"), 3)
objects = self.objects_are(f"{s} 3", f"{name}_1: part", f"{name}_2: part", f"{name}: part, part")
self.t.equal(f"{s} 3: the parts' names", [p["name"] for p in objects[2]["parts"]], [f"{name}_1", f"{name}_2"])
self.rings(f"{s} 3: the parts", [p["bbox"] for p in objects[2]["parts"]])
after4 = (f"{name}: part, part", "Assembly: part, part")
reply = self.run("object_assemble", objects=[0, 1])
self.t.equal(f"{s} 4: the reply's object and name", (reply.get("object"), reply.get("name")), (1, "Assembly"))
objects = self.objects_are(f"{s} 4", *after4)
self.t.near(f"{s} 4: the pieces keep their places: Assembly's box", objects[1]["bbox"]["size"], RINGS_SIZE,
0.01)
reply = self.run("part_change_type", parts=[[1, 0]], type="modifier")
self.t.equal(f"{s} 5: the reply's parts", [{k: p.get(k) for k in ("object", "part", "type")}
for p in reply.get("parts", [])],
[{"object": 1, "part": 1, "type": "modifier"}])
objects = self.objects_are(f"{s} 5", f"{name}: part, part", "Assembly: part, modifier")
self.t.near(f"{s} 5: a modifier is left out of Assembly's box", objects[1]["bbox"]["size"], RING, 0.01)
self.undo()
objects = self.objects_are(f"{s} 6: the change was one undo step", *after4)
self.t.near(f"{s} 6: Assembly's box", objects[1]["bbox"]["size"][0], RINGS_SIZE[0], 0.01)
self.run("object_select", objects=[0])
reply = self.run("object_split", into="objects")
self.t.equal(f"{s} 7: the reply's objects", [o.get("index") for o in reply.get("objects", [])], [1, 2])
self.t.equal(f"{s} 7: the reply's object_count", reply.get("object_count"), 3)
objects = self.objects_are(f"{s} 7: no target splits the selected object, each piece named after its part",
"Assembly: part, part", f"{name}_1: part", f"{name}_2: part")
self.rings(f"{s} 7", [o["bbox"] for o in objects[1:]])
self.run("object_select", objects=[1, 2])
reply = self.run("object_assemble")
self.t.equal(f"{s} 8: the reply's object and name", (reply.get("object"), reply.get("name")), (1, "Assembly"))
self.objects_are(f"{s} 8: no target assembles the selected objects", "Assembly: part, part",
"Assembly: part, part")
def parts(self):
s = "parts"
self.start(s)
self.run("object_add_primitive", shape="cube", size=[40, 40, 10], name="block", position=self.at(100, 100, 0))
reply = self.run("part_add", object=0, type="negative", shape="cylinder", size=[6.2, 3.2],
position=self.at(100, 100, 1.6))
self.t.equal(f"{s} 1: the reply's part and part_count", (reply.get("part"), reply.get("part_count")), (1, 2))
block = self.objects_are(f"{s} 1", "block: part, negative")[0]
negative = block["parts"][1]
self.part_placed(f"{s} 1", block, 1, 100, 100, 1.6)
self.t.near(f"{s} 1: the negative part's bottom", negative["bbox"]["min"][2], 0, 0.01)
self.t.near(f"{s} 1: the negative part's height", negative["bbox"]["size"][2], 3.2, 0.01)
self.t.check(f"{s} 1: the negative part's width is 6.1 to 6.21", 6.1 <= negative["bbox"]["size"][0] <= 6.21,
negative["bbox"])
self.t.near(f"{s} 1: a negative part is left out of block's box", block["bbox"]["size"][2], 10, 0.001)
self.undo()
self.objects_are(f"{s} 2: adding a part is one undo step", "block: part")
self.redo()
self.objects_are(f"{s} 3", "block: part, negative")
reply = self.run("part_add", object=0, type="modifier", path=DRC)
self.t.equal(f"{s} 4: the reply's part and part_count", (reply.get("part"), reply.get("part_count")), (2, 3))
block = self.objects_are(f"{s} 4", "block: part, negative, modifier")[0]
self.t.equal(f"{s} 4: the modifier's name", block["parts"][2]["name"], "OrcaCube_v2.drc")
reply = self.run("part_add", object=0, type="part", shape="cube", size=[10, 10, 20],
position=self.at(125, 100, 10))
self.t.equal(f"{s} 5: parts are listed by type: the reply's part", reply.get("part"), 1)
block = self.objects_are(f"{s} 5", "block: part, part, negative, modifier")[0]
cube = block["parts"][1]
self.t.equal(f"{s} 5: the new part's name and filament", (cube["name"], cube.get("filament")),
("Generic-Cube", 1))
self.t.near(f"{s} 5: the new part's height", cube["bbox"]["size"][2], 20, 0.01)
self.t.near(f"{s} 5: block's height", block["bbox"]["size"][2], 20, 0.001)
self.run("part_add", object=0, type="support_blocker", shape="sphere", position=self.at(110, 110, 10))
block = self.objects_are(f"{s} 6", "block: part, part, negative, modifier, support_blocker")[0]
self.part_placed(f"{s} 6: the blocker", block, 4, 110, 110, 10)
after7 = "block: part, part, negative, modifier, support_blocker, precise_seam"
self.run("part_add", object=0, type="precise_seam", shape="cube", size=[2, 2, 2])
block = self.objects_are(f"{s} 7", after7)[0]
self.t.equal(f"{s} 7: the seam's subtype", block["parts"][5].get("subtype"), "center")
refusals = [("a shape and a path", {"type": "modifier", "shape": "cube", "path": DRC}, "Give shape or path"),
("a cylinder of three sizes", {"type": "modifier", "shape": "cylinder", "size": [1, 2, 3]},
"A cylinder's size is [Diameter, Height]"),
("an SVG file", {"type": "part", "path": STAR}, "SVG parts come from object_add_svg"),
("an image", {"type": "modifier", "path": HEIGHTMAP}, "The file could not be loaded")]
for case, args, words in refusals:
self.t.refused(f"{s} 8: {case} is refused", lambda: self.c.call("part_add", object=0, **args), words=words)
self.objects_are(f"{s} 8: after {case}", after7)
self.run("object_set_instances", object=0, count=2)
self.t.refused(f"{s} 9: a part on an object of two instances is refused",
lambda: self.c.call("part_add", object=0, type="modifier", shape="cube"),
words="object 0 has 2 instances")
self.objects_are(f"{s} 9", after7)
self.start(f"{s} 10")
self.run("object_add_primitive", name="scaled", **CUBE)
self.run("object_transform", object=0, scale=1.5)
reply = self.run("part_add", object=0, type="modifier", shape="cube")
self.t.equal(f"{s} 10: the reply's part", reply.get("part"), 1)
scaled = self.objects_are(f"{s} 10", "scaled: part, modifier")[0]
self.t.near(f"{s} 10: adding a shape folds the instance's scale into the parts: the instance's scale",
scaled["instances"][0]["scale"], [1, 1, 1], 0.001)
self.t.near(f"{s} 10: part 0's scale", scaled["parts"][0]["scale"], [1.5, 1.5, 1.5], 0.001)
self.t.near(f"{s} 10: the object's size", scaled["bbox"]["size"], [30, 30, 30], 0.001)
self.start(f"{s} 11")
self.run("object_add_primitive", shape="cube", size=[30, 30, 10], name="plain")
self.run("part_add", object=0, type="modifier", shape="cube", size=[10, 10, 10])
plain = self.objects_are(f"{s} 11", "plain: part, modifier")[0]
self.t.equal(f"{s} 11: the parts' names", [p["name"] for p in plain["parts"]], ["plain", "Generic-Cube"])
self.run("object_select", parts=[[0, 1]])
reply = self.run("part_change_type", type="negative")
self.t.equal(f"{s} 12: no target changes the selected part: the reply's parts",
[{k: p.get(k) for k in ("object", "part", "type")} for p in reply.get("parts", [])],
[{"object": 0, "part": 1, "type": "negative"}])
self.objects_are(f"{s} 12", "plain: part, negative")
self.run("part_change_type", parts=[[0, 1]], type="support_blocker")
self.objects_are(f"{s} 13", "plain: part, support_blocker")
self.undo()
self.objects_are(f"{s} 14: each change is one undo step", "plain: part, negative")
self.run("part_change_type", parts=[[0, 1]], type="precise_seam")
plain = self.objects_are(f"{s} 15", "plain: part, precise_seam")[0]
self.t.equal(f"{s} 15: the seam's subtype", plain["parts"][1].get("subtype"), "center")
self.run("part_change_type", parts=[[0, 1]], type="part")
self.objects_are(f"{s} 16: a seam made a part again is listed after the first part", "plain: part, part")
self.run("part_change_type", parts=[[0, 1]], type="modifier")
self.objects_are(f"{s} 16", "plain: part, modifier")
self.t.refused(f"{s} 17: the last solid part's type is refused",
lambda: self.c.call("part_change_type", parts=[[0, 0]], type="modifier"),
code="last_solid_part")
self.objects_are(f"{s} 17", "plain: part, modifier")
self.run("object_select", objects=[0])
self.t.refused(f"{s} 18: an object's row is not a part",
lambda: self.c.call("part_change_type", type="part"), code="wrong_selection")
self.objects_are(f"{s} 18", "plain: part, modifier")
self.run("object_select", objects=[0])
self.run("object_add_svg", path=STAR)
wait(self.c, "idle")
self.run("object_select", none=True)
plain = self.objects_are(f"{s} 19", "plain: part, part, modifier")[0]
svg_path = (plain["parts"][1].get("svg") or {}).get("path", "")
self.t.check(f"{s} 19: part 1's svg.path ends in star.svg", svg_path.endswith("star.svg"), svg_path)
self.t.equal(f"{s} 19: no gizmo open afterwards", self.gizmo(), None)
self.t.refused(f"{s} 20: an SVG part cannot be a support enforcer",
lambda: self.c.call("part_change_type", parts=[[0, 1]], type="support_enforcer"),
code="text_part")
self.objects_are(f"{s} 20", "plain: part, part, modifier")
self.run("object_select", objects=[0])
self.run("object_rename", name="base")
self.run("object_select", parts=[[0, 2]])
self.run("object_rename", name="infill zone")
base = self.objects_are(f"{s} 21: no target renames the selected object, then the selected part",
"base: part, part, modifier")[0]
self.t.equal(f"{s} 21: part 0 keeps its name, part 2 is renamed",
(base["parts"][0]["name"], base["parts"][2]["name"]), ("plain", "infill zone"))
self.t.refused(f"{s} 22: a name with a slash is refused", lambda: self.c.call("object_rename", name="a/b"),
code="invalid_name")
base = self.objects_are(f"{s} 22", "base: part, part, modifier")[0]
self.t.equal(f"{s} 22: part 2's name", base["parts"][2]["name"], "infill zone")
def ordering(self):
s = "ordering"
self.start(s)
places = {"tall": 30, "short": 128, "mid": 226}
for name, height in (("tall", 30), ("short", 10), ("mid", 20)):
self.run("object_add_primitive", shape="cube", size=[20, 20, height], name=name,
position=self.at(places[name], 60, 0))
self.run("object_select", none=True)
one = ['"" 3 *']
two = ['"" 3', '"" 0 *']
first = ['"" 3 *', '"" 0']
def state(label, order, plate_rows):
objects = self.objects_are(label, *order, plate_rows=plate_rows)
for obj in objects:
if obj["name"] in places:
self.placed(label, obj, places[obj["name"]], 60)
return objects
def order_is(label, reply, order, descending=None):
self.t.equal(f"{label}: the reply's order", reply.get("order"),
[{"name": n, "object": i, "plate": 0} for i, n in enumerate(order)])
if descending is None:
self.t.check(f"{label}: the reply has no descending", "descending" not in reply, reply)
else:
self.t.equal(f"{label}: the reply's descending", reply.get("descending"), descending)
objects = state(f"{s} 1", ["tall", "short", "mid"], one)
self.t.near(f"{s} 1: the heights", [o["bbox"]["size"][2] for o in objects], [30, 10, 20], 0.001)
ascending = ["short", "mid", "tall"]
reply = self.run("object_order", by="height", plate=0)
order_is(f"{s} 2", reply, ascending, False)
state(f"{s} 2", ascending, one)
reply = self.run("object_order", by="height", plate=0)
order_is(f"{s} 3: a call that gives plate sorts ascending", reply, ascending, False)
state(f"{s} 3", ascending, one)
reply = self.run("object_order", by="height", descending=True)
order_is(f"{s} 4", reply, ["tall", "mid", "short"], True)
state(f"{s} 4", ["tall", "mid", "short"], one)
reply = self.run("object_order", by="height")
order_is(f"{s} 5: from a descending order it sorts ascending", reply, ascending, False)
state(f"{s} 5", ascending, one)
reply = self.run("object_order", by="height")
order_is(f"{s} 6: an order they already have is reversed", reply, ["tall", "mid", "short"], True)
state(f"{s} 6", ["tall", "mid", "short"], one)
self.run("plate_add")
self.run("plate_select", plate=1)
self.t.refused(f"{s} 7: the current plate is empty", lambda: self.c.call("object_order", by="size"),
code="no_objects_to_order")
state(f"{s} 7", ["tall", "mid", "short"], two)
self.t.refused(f"{s} 8: all must be a boolean", lambda: self.c.call("object_order", by="size", all="every"),
words="all must be of type boolean")
state(f"{s} 8", ["tall", "mid", "short"], two)
reply = self.run("object_order", by="size", all=True)
order_is(f"{s} 9: every plate's objects, by volume", reply, ascending, False)
state(f"{s} 9", ascending, two)
reply = self.run("object_order", by="name", all=True)
order_is(f"{s} 10: by name", reply, ["mid", "short", "tall"], False)
state(f"{s} 10", ["mid", "short", "tall"], two)
self.run("plate_set_settings", plate=0, values={"print_sequence": "by object"})
state(f"{s} 11: plate_set_settings makes the plate it sets current", ["mid", "short", "tall"], first)
self.t.equal(f"{s} 11: plate 0's print_sequence",
self.c.call("plate_list", limit=500)["items"][0]["print_sequence"], "by object")
given = ["tall", "mid", "short"]
reply = self.run("object_order", plate=0, order=[2, 0, 1])
order_is(f"{s} 12", reply, given)
state(f"{s} 12", given, first)
reply = self.run("object_order", plate=0, order=[0, 1, 2])
self.t.equal(f"{s} 13: the order they have changes nothing: the reply's order", reply.get("order"),
[{"name": n, "object": i, "plate": 0} for i, n in enumerate(given)])
state(f"{s} 13", given, first)
self.undo()
state(f"{s} 14: step 12 was one undo step and step 13 took none", ["mid", "short", "tall"], first)
self.redo()
state(f"{s} 15", given, first)
reply = self.run("plate_slice", plates=0)
self.t.equal(f"{s} 16: the slice's outcome", [p.get("outcome") for p in reply.get("plates", [])], ["ok"])
path = self.file("order.gcode")
self.run("project_export", format="gcode", plates=0, path=path)
self.t.equal(f"{s} 16: the list's order is the print order", [name for name, _ in gcode_prints(path)], given)
state(f"{s} 16", given, first)
def repairing(self):
s = "repairing a mesh"
self.start(s)
holed = self.file("holed.stl")
def edges_are(label, *edges):
objects = self.objects_are(label, *["holed.stl"] * len(edges))
self.t.equal(f"{label}: open_edges", [o["mesh_errors"]["open_edges"] for o in objects], list(edges))
self.placed(label, objects[0], 60, 60)
if len(objects) > 1:
self.placed(label, objects[1], 128, 128)
return objects
self.run("project_import", paths=[holed])
self.run("object_transform", object=0, position=self.at(60, 60, 0))
objects = edges_are(f"{s} 1", 3)
self.t.equal(f"{s} 1: manifold", objects[0]["mesh_errors"]["manifold"], False)
reply = self.c.call("object_fix", objects=[0])
self.t.check(f"{s} 2: the reply has no status: the call waited for the repair", "status" not in reply, reply)
self.t.equal(f"{s} 2: the reply's objects", [o.get("index") for o in reply.get("objects", [])], [0])
repairs = [{"object": r.get("object"), "changed": r.get("changed"),
"before": (r.get("mesh_errors_before") or {}).get("open_edges"),
"after": (r.get("mesh_errors_after") or {}).get("open_edges"),
"painting_removed": r.get("painting_removed")} for r in reply.get("repairs", [])]
self.t.equal(f"{s} 2: the reply's repairs", repairs,
[{"object": 0, "changed": True, "before": 3, "after": 0, "painting_removed": False}])
objects = edges_are(f"{s} 2", 0)
self.t.equal(f"{s} 2: manifold", objects[0]["mesh_errors"]["manifold"], True)
self.t.equal(f"{s} 2: no dialog", self.dialogs(), [])
notices = self.notices()
self.t.equal(f"{s} 2: no notice of Fix Model",
[n for n in notices if any(ending in n for ending in REPAIR_ENDINGS)], [])
self.undo()
edges_are(f"{s} 3: the repair was one undo step", 3)
self.redo()
edges_are(f"{s} 4", 0)
self.run("project_import", paths=[holed])
self.run("object_transform", object=1, position=self.at(128, 128, 0))
self.run("view_set", camera="iso")
self.run("view_set", camera="fit_objects")
self.run("object_select", objects=[1])
# The 3D view draws the moved object before the click, so that it finds the object under the pointer.
wait(self.c, "idle")
reply = self.c.call("mouse_gesture", action="click", button="right", at={"object": 1, "spot": "top"},
popup_item="Modify>Fix Model")
self.t.equal(f"{s} 5: the gesture's reply", reply.get("ran"), "Modify>Fix Model")
# The menu item's command runs after the gesture's reply, and its notice comes once it has repaired.
deadline = time.monotonic() + 30
while True:
edges = [o["mesh_errors"]["open_edges"] for o in scene(self.c)]
notices = self.notices()
met = edges[1:] == [0] and any("has been repaired" in n for n in notices)
if met or time.monotonic() > deadline:
break
time.sleep(0.2)
self.t.check(f"{s} 5: within 30 s object 1 is repaired and a notice says it has been repaired", met,
(edges, notices))
edges_are(f"{s} 5", 0, 0)
self.undo()
edges_are(f"{s} 6: the menu item's repair was one undo step", 0, 3)
def files(self):
s = "the files a part comes from"
self.start(s)
reload = self.file("reload.stl")
shutil.copyfile(self.file("cube20.stl"), reload)
self.run("project_import", paths=[reload])
self.run("object_transform", object=0, position=self.at(100, 100, 0))
def volume_is(label, volume):
obj = self.objects_are(label, "reload.stl: part")[0]
self.t.near(f"{label}: part 0's mesh_volume", obj["parts"][0]["mesh_volume"], volume, 0.001)
self.placed(label, obj, 100, 100)
return obj
volume_is(f"{s} 1", 8000)
shutil.copyfile(self.file("cube30.stl"), reload)
reply = self.run("object_reload_from_disk", objects=[0])
reloaded = reply.get("reloaded", [])
self.t.equal(f"{s} 2: the reply's reloaded", [{k: r.get(k) for k in ("object", "part")} for r in reloaded],
[{"object": 0, "part": 0}])
self.t.check(f"{s} 2: the reloaded path ends in reload.stl",
all(r.get("path", "").endswith("reload.stl") for r in reloaded), reloaded)
self.t.equal(f"{s} 2: the reply's missing and unmatched", (reply.get("missing"), reply.get("unmatched")),
([], []))
self.t.check(f"{s} 2: the reply has no unreadable", "unreadable" not in reply, reply)
obj = volume_is(f"{s} 2", 27000)
self.t.near(f"{s} 2: the object rests on the bed", obj["instances"][0]["bbox"]["min"][2], 0, 0.001)
self.undo()
volume_is(f"{s} 3: the reload was one undo step", 8000)
self.redo()
volume_is(f"{s} 4", 27000)
os.remove(reload)
reply = self.run("object_reload_from_disk", objects=[0])
missing = reply.get("missing", [])
self.t.equal(f"{s} 5: the reply's missing", [{k: r.get(k) for k in ("object", "part")} for r in missing],
[{"object": 0, "part": 0}])
self.t.check(f"{s} 5: the missing path ends in reload.stl",
all(r.get("path", "").endswith("reload.stl") for r in missing), missing)
self.t.equal(f"{s} 5: the reply's reloaded", reply.get("reloaded"), [])
self.t.equal(f"{s} 5: no file dialog asks for it", self.dialogs(), [])
volume_is(f"{s} 5", 27000)
self.undo()
volume_is(f"{s} 6: the call that reloaded nothing took no undo step", 8000)
self.start(f"{s} 7")
self.run("filament_add")
self.run("project_import", paths=[self.file("cube20.stl")])
self.run("object_transform", object=0, position=self.at(100, 100, 0))
self.run("part_add", object=0, type="modifier", shape="cylinder", size=[10, 10], position=self.at(100, 100, 10))
self.run("settings_set", type="process", target="part", object=0, part=0, values={"extruder": 2})
def parts_are(label):
obj = self.objects_are(label, "cube20.stl: part, modifier")[0]
self.placed(label, obj, 100, 100)
return obj
def part0_is(label, obj, triangles):
part = obj["parts"][0]
self.t.equal(f"{label}: part 0's filament and triangles", (part.get("filament"), part["triangles"]),
(2, triangles))
self.t.near(f"{label}: part 0's mesh_volume", part["mesh_volume"], 8000, 0.001)
self.part_placed(label, obj, 0, 100, 100, 10)
def part1_is_cylinder(label, obj):
part = obj["parts"][1]
self.t.check(f"{label}: part 1 has no filament", "filament" not in part, part)
self.t.check(f"{label}: part 1's mesh_volume under 785.4", part["mesh_volume"] < 785.4,
part["mesh_volume"])
self.part_placed(label, obj, 1, 100, 100, 10)
obj = parts_are(f"{s} 7")
part0_is(f"{s} 7", obj, 12)
part1_is_cylinder(f"{s} 7", obj)
old_id = obj["parts"][0]["id"]
reply = self.run("part_replace", object=0, part=0, path=self.file("top4.stl"))
obj = parts_are(f"{s} 8")
replaced = reply.get("parts", [])
self.t.equal(f"{s} 8: the reply's parts", [{k: p.get(k) for k in ("object", "part", "name")} for p in replaced],
[{"object": 0, "part": 0, "name": "top4.stl"}])
new_id = replaced[0].get("part_id") if replaced else None
self.t.check(f"{s} 8: the reply's part_id is new and the one object_list gives",
new_id != old_id and new_id == obj["parts"][0]["id"], (old_id, new_id, obj["parts"][0]["id"]))
part0_is(f"{s} 8: the part keeps its type, filament and place", obj, 14)
part1_is_cylinder(f"{s} 8", obj)
self.run("part_replace", object=0, part=1, path=self.file("top4.stl"))
obj = parts_are(f"{s} 9")
part = obj["parts"][1]
self.t.check(f"{s} 9: part 1 has no filament", "filament" not in part, part)
self.t.equal(f"{s} 9: part 1's triangles", part["triangles"], 14)
self.t.near(f"{s} 9: part 1's mesh_volume", part["mesh_volume"], 8000, 0.001)
self.part_placed(f"{s} 9: the mesh keeps its place in its file", obj, 1, 110, 110, 15, 0.05)
self.undo()
part1_is_cylinder(f"{s} 10", parts_are(f"{s} 10"))
self.undo()
obj = parts_are(f"{s} 11: each replace was one undo step")
self.t.equal(f"{s} 11: part 0's triangles", obj["parts"][0]["triangles"], 12)
def painting(self):
s = "painting kept through a mesh change"
self.start(s)
painted = self.file("painted.stl")
shutil.copyfile(self.file("cube20.stl"), painted)
self.run("project_import", paths=[painted])
self.run("view_set", camera="front")
self.run("view_set", camera="fit_objects")
self.run("object_select", objects=[0])
wait(self.c, "idle")
reply = self.c.call("widget_click", target={"gizmo": "FdmSupports"})
self.t.equal(f"{s} 1: the Paint-on supports gizmo opens", reply.get("active"), True)
self.c.call("widget_click", target={"imgui_name": "Fill"})
self.c.call("mouse_gesture", at={"object": 0, "spot": "front"})
self.c.call("widget_click", target={"imgui": "Done"})
wait(self.c, "idle")
def enforcers(label, name, more=True):
part = self.objects_are(label, f"{name}: part")[0]["parts"][0]
count = ((part.get("painted") or {}).get("supports") or {}).get("enforcers")
if more:
self.t.check(f"{label}: part 0 has painted enforcers", isinstance(count, int) and count > 0,
part.get("painted"))
else:
self.t.check(f"{label}: part 0 has no painting", "painted" not in part, part.get("painted"))
return part
def preference(label, value):
items = self.c.call("preferences_get", keys=["keep_painting"])["items"]
self.t.equal(f"{label}: keep_painting", [i.get("value") for i in items], [value])
enforcers(f"{s} 1", "painted.stl")
self.t.equal(f"{s} 1: no gizmo open afterwards", self.gizmo(), None)
self.run("preferences_set", values={"keep_painting": False})
reply = self.run("object_reload_from_disk", objects=[0])
self.t.equal(f"{s} 2: the reply's reloaded", [{k: r.get(k) for k in ("object", "part")}
for r in reply.get("reloaded", [])], [{"object": 0, "part": 0}])
enforcers(f"{s} 2: with the preference off a reload drops the painting", "painted.stl", more=False)
preference(f"{s} 2", False)
self.undo()
enforcers(f"{s} 3", "painted.stl")
self.run("preferences_set", values={"keep_painting": True})
self.run("object_reload_from_disk", objects=[0])
enforcers(f"{s} 4: with it on the same call keeps the painting", "painted.stl")
preference(f"{s} 4", True)
self.run("part_replace", object=0, part=0, path=self.file("top4.stl"))
part = enforcers(f"{s} 5: the painting is carried onto a mesh of other triangles", "top4.stl")
self.t.equal(f"{s} 5: part 0's triangles", part["triangles"], 14)
self.run("preferences_set", values={"keep_painting": False})
enforcers(f"{s} 6", "top4.stl")
preference(f"{s} 6: the preference as the test found it", False)
def keeps(self):
s = "what the project keeps"
self.start(s)
self.run("object_add_primitive", shape="cube", size=[30, 30, 10], name="base", position=self.at(60, 60, 0))
self.run("part_add", object=0, type="negative", shape="cylinder", size=[6, 3], position=self.at(60, 60, 1.5))
self.run("part_add", object=0, type="modifier", shape="cube", size=[10, 10, 10], position=self.at(60, 60, 5))
self.run("part_add", object=0, type="precise_seam", shape="cube", size=[2, 2, 2], position=self.at(75, 60, 5))
self.run("object_rename", object=0, part=2, name="infill zone")
self.run("part_change_type", parts=[[0, 3]], type="precise_seam", subtype="left")
self.run("object_add_primitive", name="other", position=self.at(180, 180, 0), **CUBE)
self.run("object_order", plate=0, order=[1, 0])
def kept(label):
base = self.objects_are(label, "other: part", "base: part, negative, modifier, precise_seam")[1]
self.t.equal(f"{label}: base's parts' names", [p["name"] for p in base["parts"]],
["base", "Generic-Cylinder", "infill zone", "Generic-Cube"])
for i, place in enumerate([(60, 60, 5), (60, 60, 1.5), (60, 60, 5), (75, 60, 5)]):
self.part_placed(label, base, i, *place)
self.t.equal(f"{label}: the seam's subtype", base["parts"][3].get("subtype"), "left")
kept(f"{s} 1")
path = self.file("keeps.3mf")
self.run("project_save", path=path, overwrite=True)
self.run("project_new", discard_changes=True)
self.empty(f"{s} 2: the new project")
self.run("project_open", path=path)
wait(self.c, "idle")
kept(f"{s} 2: the project file keeps them")
def run_all(self):
for name, scenario in [("renaming and deleting", self.renaming), ("splitting and assembling", self.splitting),
("parts", self.parts), ("ordering", self.ordering),
("repairing a mesh", self.repairing), ("the files a part comes from", self.files),
("painting kept through a mesh change", self.painting),
("what the project keeps", self.keeps)]:
self.t.scenario(name, scenario)
try: # the preference as the test found it, should the painting scenario have broken off
self.c.call("preferences_set", values={"keep_painting": False})
self.run("project_new", discard_changes=True)
except orca_mcp.McpError as e:
print(f"cleaning up: {e}", flush=True)
return self.t.exit_code()
def main():
client, _ = orca_mcp.session_client()
with tempfile.TemporaryDirectory(prefix="orca-structure-", ignore_cleanup_errors=True) as folder:
return ObjectStructureTest(client, folder).run_all()
if __name__ == "__main__":
sys.exit(main())
+918
View File
@@ -0,0 +1,918 @@
#!/usr/bin/env python3
"""Where objects stand and how many there are, as the test_objects entry of tools/mcp/test-entries/objects.md designs
them.
tools/mcp/orca_mcp.py launch
tools/mcp/test_objects.py [scenario ...]
Adding a shape at a size, a place, a plate and a name; moving, turning and scaling an instance, moving it to another
plate, and Auto Drop; moving and scaling a part, the selection and Mirror; the number of instances and Set as
Individual Objects; Drop to Bed, Center, Scale to Fit and Auto-Orient; Arrange and Fill bed; Clone; leaving instances
out of the print; and what the project file keeps. After every step the test reads the plates with plate_list and every
object and instance with object_list, and compares them with the state the entry writes out: the objects' names,
plates and instance counts, and each instance's place, turn, scale, mirror, printable flag, height above the bed and
Auto Drop. It runs on the harness's default printer, the Bambu Lab X1 Carbon 0.4, and exits 0 when every check passes.
Scenarios named on the command line (by their method names, such as arranging) run alone.
"""
import copy
import math
import os
import sys
import tempfile
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import orca_mcp # noqa: E402
from checks import (Checks, apart, corner, gap, gcode_prints, inside, plates, rect, run, scene, selection, # noqa: E402
square, wait)
from test_plates import P, turn # noqa: E402
CUBE = {"shape": "cube", "size": [20, 20, 20]}
def close(got, want, tolerance):
return len(got) == len(want) and all(abs(g - w) <= tolerance for g, w in zip(got, want))
def row_of(obj):
"""An object as the entry's tables write it: its name, @ and the plate its instances stand on, and ×n for n
instances."""
on = sorted({inst["plate"] for inst in obj["instances"]})
n = len(obj["instances"])
return f"{obj['name']}@{','.join(map(str, on))}" + (f"×{n}" if n > 1 else "")
def I(plate, at=None, **values):
"""What one instance must hold: its plate and place +(x, y) from that plate's corner (None: the app places it),
and by default no turn, no scale, no mirror, printable and resting on the bed. A value of None is not compared."""
out = {"plate": plate, "at": at, "rot": [0, 0, 0], "scale": [1, 1, 1], "mirrored": False, "printable": True,
"z": 0}
out.update(values)
return out
def named(reply, key="objects"):
"""The (index, name) pairs a reply's list of objects gives."""
return [(o.get("index"), o.get("name")) for o in reply.get(key, [])]
class ObjectsTest:
def __init__(self, client, folder):
self.c = client
self.t = Checks()
self.folder = folder
self.want = []
# ---- Calls ----
def run(self, tool, **args):
return run(self.c, tool, **args)
def undo(self):
self.run("undo", history="project")
def redo_to(self, state):
"""Redoes the last step undone; the objects are then expected as `state`."""
self.run("redo", history="project")
self.want = copy.deepcopy(state)
def refused(self, label, tool, code=None, words=None, **args):
return self.t.refused(label, lambda: self.c.call(tool, **args), code=code, words=words)
def corner(self, plate, dx, dy, z=0):
cx, cy = corner(self.c, plate)
return [cx + dx, cy + dy, z]
# ---- What the test expects ----
def add(self, name, *instances, auto_drop=True):
self.want.append({"name": name, "auto_drop": auto_drop, "inst": list(instances)})
def inst(self, obj, i=0):
return self.want[obj]["inst"][i]
def by_name(self, name):
found = [w for w in self.want if w["name"] == name]
assert len(found) == 1, f"{len(found)} objects named {name}"
return found[0]
def saved(self):
return copy.deepcopy(self.want)
# ---- Reading the state back ----
def start(self, name):
self.run("project_new", discard_changes=True)
self.run("view_set", tab="prepare")
wait(self.c, "idle")
self.want = []
self.empty(f"{name}: the start")
def empty(self, label):
"""What project_new leaves: one empty plate, current, and no objects."""
self.t.equal(f"{label}: the plates", plates(self.c), P('"" 0 *'))
self.t.equal(f"{label}: no objects", scene(self.c), [])
def expect(self, label, plates_row, objects_row, any_order=False):
"""Compares plates() with plates_row, the objects' names, plates and instance counts with objects_row, and
every instance with what self.want holds for it; gives scene() for the step's own checks."""
self.t.equal(f"{label}: the plates", plates(self.c), P(*plates_row.split(" · ")))
sc = scene(self.c)
got, want = [row_of(o) for o in sc], objects_row.split(" · ") if objects_row else []
if any_order:
got, want = sorted(got), sorted(want)
self.t.equal(f"{label}: the objects", got, want)
self.placements(label, sc, any_order)
return sc
def placements(self, label, sc, by_name):
corners = [item["origin"] for item in self.c.call("plate_list", limit=500)["items"]]
problems = []
if len(sc) != len(self.want):
problems.append(f"{len(sc)} objects, the test expects {len(self.want)}")
pairs = [(o, self.by_name(o["name"])) for o in sc] if by_name else zip(sc, self.want)
for obj, want in pairs:
who = f"object {obj['index']} ({obj['name']})"
if obj["auto_drop"] != want["auto_drop"]:
problems.append(f"{who}: auto_drop {obj['auto_drop']}")
if len(obj["instances"]) != len(want["inst"]):
problems.append(f"{who}: {len(obj['instances'])} instances, the test expects {len(want['inst'])}")
continue
for inst, w in zip(obj["instances"], want["inst"]):
where = f"{who} instance {inst['index']}"
if w["at"] is not None and inst["plate"] >= 0:
cx, cy = corners[inst["plate"]]
at = [inst["offset"][0] - cx, inst["offset"][1] - cy]
if not close(at, w["at"], 0.001):
problems.append(f"{where}: at +({at[0]:.3f}, {at[1]:.3f}), expected +{tuple(w['at'])}")
if w["rot"] is not None and not close(turn(inst["rotation_deg"]), turn(w["rot"]), 1e-6):
problems.append(f"{where}: rotation_deg {inst['rotation_deg']}, expected {w['rot']}")
if w["scale"] is not None and not close(inst["scale"], w["scale"], 0.001):
problems.append(f"{where}: scale {inst['scale']}, expected {w['scale']}")
for key in ("mirrored", "printable"):
if inst[key] != w[key]:
problems.append(f"{where}: {key} {inst[key]}")
if w["z"] is not None and abs(inst["bbox"]["min"][2] - w["z"]) > 0.001:
problems.append(f"{where}: bbox.min z {inst['bbox']['min'][2]}, expected {w['z']}")
self.t.check(f"{label}: every instance as expected", not problems, "; ".join(problems))
def find(self, sc, name):
found = [o for o in sc if o["name"] == name]
assert len(found) == 1, f"{len(found)} objects named {name}"
return found[0]
def squares(self, sc, plate):
return [square(i) for o in sc for i in o["instances"] if i["plate"] == plate]
def spread_on(self, label, plate, squares):
"""The squares lie inside the plate's rectangle, each apart from every other."""
r = rect(self.c, plate)
self.t.check(f"{label}: every square inside plate {plate}", all(inside(s, r) for s in squares), (squares, r))
crossing = [(a, b) for i, a in enumerate(squares) for b in squares[i + 1:] if not apart(a, b)]
self.t.check(f"{label}: the squares apart", not crossing, crossing)
def size(self, label, inst, want, tolerance=0.01):
self.t.near(f"{label}: bbox.size", inst["bbox"]["size"], want, tolerance)
# ---- Scenarios ----
def adding(self):
s = "adding a shape"
self.start(s)
self.run("plate_add")
self.run("plate_add")
self.expect(f"{s} 1", '"" 0 · "" 0 · "" 0 *', "")
reply = self.run("object_add_primitive", plate=1, name="first", **CUBE)
self.t.equal(f"{s} 2: the reply's object, plate and objects", (reply.get("object"), reply.get("plate"),
named(reply)), (0, 1, [(0, "first")]))
self.add("first", I(1))
sc = self.expect(f"{s} 2", '"" 0 · "" 1 * · "" 0', "first@1")
self.spread_on(f"{s} 2: first", 1, self.squares(sc, 1))
self.size(f"{s} 2: first's", sc[0]["instances"][0], [20, 20, 20])
self.t.equal(f"{s} 2: selection() objects", selection(self.c)["objects"], [0])
after2 = self.saved()
reply = self.run("object_add_primitive", name="second", position=self.corner(1, 112.8, 110), **CUBE)
self.t.equal(f"{s} 3: the reply's object and plate", (reply.get("object"), reply.get("plate")), (1, 1))
self.t.near(f"{s} 3: the reply's offset", reply.get("offset"), self.corner(1, 112.8, 110, 10), 0.001)
self.add("second", I(1, (112.8, 110)))
after3 = self.saved()
self.expect(f"{s} 3", '"" 0 · "" 2 * · "" 0', "first@1 · second@1")
self.t.equal(f"{s} 3: a size adds the shape whatever is selected, and selects it",
selection(self.c)["objects"], [1])
self.undo()
self.want = after2
self.expect(f"{s} 4: adding, naming and placing second were one undo step", '"" 0 · "" 1 * · "" 0', "first@1")
self.redo_to(after3)
self.expect(f"{s} 5", '"" 0 · "" 2 * · "" 0', "first@1 · second@1")
self.run("object_select", none=True)
self.run("object_add_primitive", shape="cube", size=[40, 30, 10])
self.add("Cube", I(1))
sc = self.expect(f"{s} 6: named after its shape", '"" 0 · "" 3 * · "" 0', "first@1 · second@1 · Cube@1")
self.size(f"{s} 6: Cube's", sc[2]["instances"][0], [40, 30, 10])
self.spread_on(f"{s} 6: Cube", 1, [square(sc[2]["instances"][0])])
self.refused(f"{s} 7: a cylinder's size of three is refused", "object_add_primitive",
words="A cylinder's size is [Diameter, Height]", shape="cylinder", size=[1, 2, 3])
self.expect(f"{s} 7", '"" 0 · "" 3 * · "" 0', "first@1 · second@1 · Cube@1")
def moving(self):
s = "moving an instance"
self.start(s)
self.run("object_add_primitive", name="block", position=self.corner(0, 100, 100), **CUBE)
self.run("object_select", none=True)
self.run("object_add_primitive", name="other", position=self.corner(0, 200, 200), **CUBE)
self.add("block", I(0, (100, 100)))
self.add("other", I(0, (200, 200)))
rows = '"" 2 *', "block@0 · other@0"
self.expect(f"{s} 1", *rows)
block = self.inst(0)
steps = [
(2, {"scale": 1.5}, {"scale": [1.5] * 3}, [30, 30, 30], "a scale that grows it drops it back"),
(3, {"size": [45, None, None]}, {"scale": [2.25] * 3}, [45, 45, 45], "one size keeps the proportions"),
(4, {"size": [30, 20, 10]}, {"scale": [1.5, 1, 0.5]}, [30, 20, 10], ""),
(5, {"rotate": [0, 0, 30], "mode": "absolute"}, {"rot": [0, 0, 30]}, [35.98, 32.32, 10], ""),
(6, {"rotate": [0, 0, 15]}, {"rot": [0, 0, 45]}, [35.36, 35.36, 10], "a call is relative by default"),
(7, {"translate": [10, -20, 0]}, {"at": (110, 80)}, None, ""),
(8, {"position": self.corner(0, 50, 60)}, {"at": (50, 60)}, None, "position is where it goes"),
]
for step, args, change, box, why in steps:
self.run("object_transform", object=0, **args)
block.update(change)
sc = self.expect(f"{s} {step}" + (f": {why}" if why else ""), *rows)
if box:
self.size(f"{s} {step}: block's", sc[0]["instances"][0], box)
self.run("plate_add")
self.expect(f"{s} 9", '"" 2 · "" 0 *', rows[1])
reply = self.run("object_transform", object=0, plate=1)
self.t.equal(f"{s} 10: the reply's plate", reply.get("plate"), 1)
block["plate"] = 1
self.expect(f"{s} 10", '"" 1 · "" 1 *', "block@1 · other@0")
listing = self.c.call("object_list", plate=1)["plates"]
self.t.equal(f"{s} 10: object_list of plate 1 lists block alone, with its instance 0",
[(p["index"], [(o["name"], [i["index"] for i in o["instances"]]) for o in p["objects"]])
for p in listing], [(1, [("block", [0])])])
self.run("object_transform", object=0, plate=0)
block["plate"] = 0
rows = '"" 2 · "" 0 *', "block@0 · other@0"
self.expect(f"{s} 11: moving an instance leaves the current plate", *rows)
self.run("object_transform", object=0, translate=[0, 0, 15])
self.expect(f"{s} 12: with Auto Drop on, a lifted object drops", *rows)
reply = self.run("object_set_auto_drop", objects=[0], auto_drop=False)
self.t.equal(f"{s} 13: the reply", (named(reply), reply.get("auto_drop")), ([(0, "block")], False))
self.want[0]["auto_drop"] = False
after13 = self.saved()
self.expect(f"{s} 13", *rows)
self.run("object_transform", object=1, translate=[0, 0, 15])
self.expect(f"{s} 14: other's Auto Drop is on", *rows)
self.run("object_transform", object=0, translate=[0, 0, 15])
block["z"] = 15
sc = self.expect(f"{s} 15: with Auto Drop off it stays where it is moved", *rows)
self.t.near(f"{s} 15: block's bbox.max z", sc[0]["instances"][0]["bbox"]["max"][2], 25, 0.001)
self.undo()
self.want = after13
self.expect(f"{s} 16: the move was one undo step", *rows)
def parts_are(self, label, sc, obj, wants):
"""Each part of object `obj` as `wants` gives it: name, type, place +(x, y, z) from its instance's plate's
corner, scale, mirror and, where not None, turn."""
cx, cy = corner(self.c, sc[obj]["instances"][0]["plate"])
problems = []
parts = sc[obj]["parts"]
if len(parts) != len(wants):
problems.append(f"{len(parts)} parts, the test expects {len(wants)}")
for part, w in zip(parts, wants):
where = f"part {part['index']}"
at = [part["position"][0] - cx, part["position"][1] - cy, part["position"][2]]
if (part["name"], part["type"]) != (w["name"], w["type"]):
problems.append(f"{where}: {part['name']!r} of type {part['type']}")
if not close(at, w["at"], 0.001):
problems.append(f"{where}: at +({at[0]:.3f}, {at[1]:.3f}, {at[2]:.3f}), expected +{tuple(w['at'])}")
if not close(part["scale"], w["scale"], 0.001):
problems.append(f"{where}: scale {part['scale']}, expected {w['scale']}")
if w["rot"] is not None and not close(turn(part["rotation_deg"]), turn(w["rot"]), 1e-6):
problems.append(f"{where}: rotation_deg {part['rotation_deg']}, expected {w['rot']}")
if part["mirrored"] != w["mirrored"]:
problems.append(f"{where}: mirrored {part['mirrored']}")
self.t.check(f"{label}: the parts of {sc[obj]['name']}", not problems, "; ".join(problems))
def moving_a_part(self):
s = "moving a part"
self.start(s)
self.run("object_add_primitive", shape="cube", size=[30, 30, 10], name="base",
position=self.corner(0, 100, 100))
self.run("object_select", none=True)
self.run("object_add_primitive", name="single", position=self.corner(0, 200, 200), **CUBE)
self.add("base", I(0, (100, 100)))
self.add("single", I(0, (200, 200)))
rows = '"" 2 *', "base@0 · single@0"
def part(at, **values):
"""Part 1 of base, the cube part_add adds, at +(x, y, z): unturned, unscaled and not mirrored by default."""
return {"name": "Generic-Cube", "type": "part", "at": at, "scale": [1, 1, 1], "rot": [0, 0, 0],
"mirrored": False, **values}
part0 = {"name": "base", "type": "part", "at": (100, 100, 5), "scale": [1, 1, 1], "rot": [0, 0, 0],
"mirrored": False}
def step(label, part1, base0=part0):
sc = self.expect(label, *rows)
self.parts_are(label, sc, 0, [base0, part1])
return sc
reply = self.run("part_add", object=0, type="part", shape="cube", size=[10, 10, 10],
position=self.corner(0, 120, 100, 15))
self.t.equal(f"{s} 1: the reply's part and part_count", (reply.get("part"), reply.get("part_count")), (1, 2))
sc = step(f"{s} 1", part((120, 100, 15)))
p1 = sc[0]["parts"][1]
self.t.equal(f"{s} 1: part 1's filament and triangles", (p1.get("filament"), p1["triangles"]), (1, 12))
self.t.near(f"{s} 1: part 1's mesh_volume and scaled_volume", [p1["mesh_volume"], p1["scaled_volume"]],
[1000, 1000], 0.001)
self.t.near(f"{s} 1: base's bbox.size", sc[0]["bbox"]["size"], [40, 30, 20], 0.001)
self.run("object_transform", object=0, size=[60, None, None])
self.inst(0)["scale"] = [1.5] * 3
sc = step(f"{s} 2: the size scales both parts about the instance's place", part((130, 100, 22.5)),
base0={**part0, "at": (100, 100, 7.5)})
self.t.near(f"{s} 2: base's bbox.size", sc[0]["bbox"]["size"], [60, 45, 30], 0.001)
self.undo()
self.inst(0)["scale"] = [1, 1, 1]
step(f"{s} 3", part((120, 100, 15)))
reply = self.run("object_transform", object=0, part=1, translate=self.corner(0, 110, 100, 15), mode="absolute")
self.t.near(f"{s} 4: the reply's part_info.position", reply.get("part_info", {}).get("position"),
self.corner(0, 110, 100, 15), 0.001)
step(f"{s} 4", part((110, 100, 15)))
self.run("object_transform", object=0, part=1, translate=[5, 0, 0])
step(f"{s} 5", part((115, 100, 15)))
self.undo()
step(f"{s} 6: each part move is one undo step", part((110, 100, 15)))
reply = self.run("object_transform", object=0, part=1, scale=2, mode="absolute")
self.t.near(f"{s} 7: the reply's size", reply.get("size"), [20, 20, 20], 0.001)
sc = step(f"{s} 7", part((110, 100, 15), scale=[2, 2, 2]))
self.t.near(f"{s} 7: part 1's scaled_volume", sc[0]["parts"][1]["scaled_volume"], 8000, 0.001)
reply = self.run("object_transform", object=0, part=1, size=[None, None, 3])
self.t.near(f"{s} 8: the reply's size: one size keeps the proportions", reply.get("size"), [3, 3, 3], 0.001)
sc = step(f"{s} 8", part((110, 100, 15), scale=[0.3] * 3))
self.t.near(f"{s} 8: part 1's mesh_volume and scaled_volume",
[sc[0]["parts"][1]["mesh_volume"], sc[0]["parts"][1]["scaled_volume"]], [1000, 27], 0.001)
self.run("object_transform", object=0, part=1, rotate=[0, 0, 45])
turned = part((110, 100, 15), scale=[0.3] * 3, rot=[0, 0, 45])
step(f"{s} 9", turned)
refusals = [
(10, {"object": 0, "part": 1, "rotate": [0, 0, 0], "mode": "absolute"},
"rotate a part relative to its current rotation"),
(11, {"object": 0, "part": 1, "plate": 1}, "plate moves an instance"),
(12, {"object": 1, "part": 0, "translate": [1, 0, 0]}, "object 1 has one part"),
]
for n, args, words in refusals:
self.refused(f"{s} {n}: refused", "object_transform", words=words, **args)
step(f"{s} {n}", turned)
reply = self.run("object_select", parts=[[0, 1]])
self.t.equal(f"{s} 13: the reply", reply, {"canvas": "3d", "empty": False, "objects": [0],
"instances": [[0, 0]], "parts": [[0, 1]]})
self.t.equal(f"{s} 13: selection()", selection(self.c), {"objects": [0], "instances": [[0, 0]],
"parts": [[0, 1]]})
step(f"{s} 13", turned)
reply = self.run("object_select", objects=[0])
self.t.equal(f"{s} 14: the reply lists no parts for a whole instance",
{k: reply.get(k) for k in ("objects", "instances", "parts")},
{"objects": [0], "instances": [[0, 0]], "parts": None})
self.t.equal(f"{s} 14: selection()", selection(self.c), {"objects": [0], "instances": [[0, 0]]})
step(f"{s} 14", turned)
reply = self.run("object_mirror", parts=[[0, 1]], axis="x")
self.t.equal(f"{s} 15: the reply names part 1 of base",
[(p.get("object"), p.get("part")) for p in reply.get("parts", [])], [(0, 1)])
mirrored = part((110, 100, 15), scale=[0.3] * 3, rot=None, mirrored=True)
step(f"{s} 15: a part mirrors in its place", mirrored)
self.run("object_mirror", objects=[0], axis="x")
self.inst(0)["mirrored"] = True
step(f"{s} 16: an instance mirrors about the centre of the selection's box",
{**mirrored, "at": (90, 100, 15)})
self.run("object_mirror", objects=[0], axis="y")
self.inst(0).update(mirrored=False, rot=[0, 0, 180])
step(f"{s} 17: a mirror along X and one along Y make a half turn", {**mirrored, "at": (90, 100, 15)})
self.run("object_select", none=True)
self.refused(f"{s} 18: a mirror of nothing selected is refused", "object_mirror", code="nothing_selected",
axis="x")
step(f"{s} 18", {**mirrored, "at": (90, 100, 15)})
def instances(self):
s = "the number of instances"
self.start(s)
self.run("object_add_primitive", name="a", position=self.corner(0, 60, 60), **CUBE)
self.run("object_select", none=True)
self.run("object_add_primitive", name="b", position=self.corner(0, 180, 60), **CUBE)
self.run("part_add", object=1, type="modifier", shape="cube", size=[5, 5, 5])
def a(n):
"""a's n instances: each one a call adds goes 12.8 mm further along x and y than the one before."""
return [I(0, (60 + 12.8 * k, 60 + 12.8 * k)) for k in range(n)]
self.add("a", *a(1))
self.add("b", I(0, (180, 60)))
after1 = self.saved()
self.expect(f"{s} 1", '"" 2 *', "a@0 · b@0")
self.run("object_select", none=True)
self.refused(f"{s} 2: no target and nothing selected is refused", "object_set_instances",
code="nothing_selected", count=3)
self.expect(f"{s} 2", '"" 2 *', "a@0 · b@0")
reply = self.run("object_set_instances", object=0, count=3)
self.t.equal(f"{s} 3: the reply", (reply.get("object"), reply.get("instances"), named(reply)),
(0, 3, [(0, "a")]))
self.want[0]["inst"] = a(3)
self.expect(f"{s} 3", '"" 2 *', "a@0×3 · b@0")
self.t.equal(f"{s} 3: selection() objects", selection(self.c)["objects"], [0])
self.undo()
self.want = copy.deepcopy(after1)
self.expect(f"{s} 4: the count was one undo step", '"" 2 *', "a@0 · b@0")
self.run("object_set_instances", object=0, count=" 2 ")
self.want[0]["inst"] = a(2)
self.expect(f"{s} 5: a count written as text is read as the number", '"" 2 *', "a@0×2 · b@0")
self.run("object_set_instances", object=0, delta=1)
self.want[0]["inst"] = a(3)
self.expect(f"{s} 6", '"" 2 *', "a@0×3 · b@0")
self.run("object_set_instances", object=0, delta=-1)
self.want[0]["inst"] = a(2)
self.expect(f"{s} 7: the last instance goes", '"" 2 *', "a@0×2 · b@0")
self.run("object_set_instances", object=0, count=1)
self.want[0]["inst"] = a(1)
self.expect(f"{s} 8", '"" 2 *', "a@0 · b@0")
for count, code, words in [(0, None, "count must be >= 1"), (-2, None, "count must be >= 1"),
(1001, "bad_instance_count", None), (2.5, None, "count must be of type integer"),
("three", None, "count must be of type integer")]:
self.refused(f"{s} 9: a count of {count!r} is refused", "object_set_instances", code=code, words=words,
object=0, count=count)
self.expect(f"{s} 9: after a count of {count!r}", '"" 2 *', "a@0 · b@0")
self.run("object_select", objects=[0, 1])
self.refused(f"{s} 10: two objects selected are refused", "object_set_instances", code="one_object_only",
count=2)
self.expect(f"{s} 10", '"" 2 *', "a@0 · b@0")
self.run("object_set_instances", object=0, count=2)
self.want[0]["inst"] = a(2)
reply = self.run("object_select", instances=[[0, 1]])
self.t.equal(f"{s} 11: the reply", (reply.get("objects"), reply.get("instances")), ([0], [[0, 1]]))
self.t.equal(f"{s} 11: selection()", selection(self.c), {"objects": [0], "instances": [[0, 1]]})
self.expect(f"{s} 11", '"" 2 *', "a@0×2 · b@0")
reply = self.run("object_select", objects=[0])
self.t.equal(f"{s} 12: the selection names the instances it is in", reply.get("instances"),
[[0, 0], [0, 1]])
self.expect(f"{s} 12", '"" 2 *', "a@0×2 · b@0")
self.run("object_select", instances=[[0, 1]])
self.run("object_set_instances", count=4)
self.want[0]["inst"] = a(4)
self.expect(f"{s} 13: the selected instance stands for its object", '"" 2 *', "a@0×4 · b@0")
self.run("object_select", parts=[[1, 1]])
self.run("object_set_instances", count=2)
self.want[1]["inst"] = [I(0, (180, 60)), I(0, (192.8, 72.8))]
self.expect(f"{s} 14: the selected part stands for its object", '"" 2 *', "a@0×4 · b@0×2")
self.run("object_set_printable", instances=[[1, 0]], printable=False)
self.inst(1, 0)["printable"] = False
self.refused(f"{s} 15: more instances of an object with one not printable are refused",
"object_set_instances", code="unprintable_instance", object=1, count=3)
self.expect(f"{s} 15", '"" 2 *', "a@0×4 · b@0×2")
self.run("object_set_instances", object=1, count=1)
self.want[1]["inst"] = [I(0, (180, 60), printable=False)]
self.expect(f"{s} 16: fewer instances need no printable rule", '"" 2 *', "a@0×4 · b@0")
self.run("object_set_printable", objects=[1], printable=True)
self.inst(1)["printable"] = True
self.run("object_select", objects=[1])
reply = self.c.call("action_run", id="obj_set_instances")
self.t.equal(f"{s} 17: the action waits on its dialog", reply.get("status"), "blocked_by_dialog")
self.t.equal(f"{s} 17: the dialog open", [d.get("title") for d in self.c.call("app_state")["dialogs"]],
["Copies of the selected object"])
self.run("dialog_answer", button="cancel")
done = wait(self.c, "job", job=reply.get("job"))
self.t.equal(f"{s} 17: the job's result after Cancel", (done.get("object"), done.get("instances")), (1, 1))
self.expect(f"{s} 17", '"" 2 *', "a@0×4 · b@0")
self.run("object_set_instances", object=1, count=2)
self.want[1]["inst"] = [I(0, (180, 60)), I(0, (192.8, 72.8))]
after_count = self.saved()
reply = self.run("object_separate_instances", object=1)
self.t.equal(f"{s} 18: the reply's objects", named(reply), [(1, "b"), (2, "b")])
self.want[1]["inst"] = [I(0, (180, 60))]
self.add("b", I(0, (192.8, 72.8)))
sc = self.expect(f"{s} 18", '"" 3 *', "a@0×4 · b@0 · b@0")
self.t.equal(f"{s} 18: each instance's object keeps the parts", [[p["type"] for p in o["parts"]] for o in sc],
[["part"], ["part", "modifier"], ["part", "modifier"]])
self.undo()
self.want = after_count
self.expect(f"{s} 19: Set as Individual Objects was one undo step", '"" 2 *', "a@0×4 · b@0×2")
reply = self.run("object_separate_instances", instances=[[0, 3]])
self.t.equal(f"{s} 20: the reply's objects", named(reply), [(2, "a")])
self.want[0]["inst"] = a(3)
self.add("a", I(0, (98.4, 98.4)))
self.expect(f"{s} 20: where the instance stood", '"" 3 *', "a@0×3 · b@0×2 · a@0")
self.run("object_select", objects=[0])
reply = self.run("object_separate_instances")
self.t.equal(f"{s} 21: the reply's objects", named(reply), [(0, "a"), (3, "a"), (4, "a")])
self.want[0]["inst"] = a(1)
self.add("a", I(0, (85.6, 85.6)))
self.add("a", I(0, (72.8, 72.8)))
self.expect(f"{s} 21: each instance but the first becomes an object, the last instance first", '"" 5 *',
"a@0 · b@0×2 · a@0 · a@0 · a@0")
self.start(f"{s} 22")
self.run("view_set", camera="top")
self.run("object_add_primitive", name="cut", **CUBE)
self.run("object_select", objects=[0])
self.c.call("widget_click", target={"gizmo": "Cut"})
self.c.call("widget_set_value", target={"imgui_name": "move_Z"}, value=10)
self.c.call("widget_click", target={"imgui": "Add connectors"})
self.c.call("mouse_gesture", at={"object": 0, "spot": "top"}, check="point")
self.c.call("widget_click", target={"imgui": "Confirm connectors"})
self.c.call("widget_click", target={"imgui": "Perform cut"})
wait(self.c, "idle")
self.refused(f"{s} 22: instances of a cut object are refused", "object_set_instances", code="cut_object",
object=0, count=2)
self.add("cut", I(0))
self.add("cut", I(0))
self.expect(f"{s} 22: the cut's halves keep one instance each", '"" 2 *', "cut@0 · cut@0")
def placing(self):
s = "placing objects"
self.start(s)
self.run("plate_add")
self.run("plate_add")
self.run("object_add_primitive", plate=1, name="first", position=self.corner(1, 40, 60), **CUBE)
self.run("object_add_primitive", plate=1, name="second", position=self.corner(1, 100, 60), **CUBE)
self.run("part_add", object=1, type="part", shape="cube", size=[5, 5, 5],
position=self.corner(1, 115, 60, 2.5))
self.run("object_add_primitive", plate=2, name="third", position=self.corner(2, 60, 60), **CUBE)
self.add("first", I(1, (40, 60)))
self.add("second", I(1, (100, 60)))
self.add("third", I(2, (60, 60)))
rows = '"" 0 · "" 2 · "" 1 *', "first@1 · second@1 · third@2"
def second_part(label, sc, at):
part = sc[1]["parts"][1]
cx, cy = corner(self.c, 1)
self.t.near(f"{label}: second's part at +{at}", [part["position"][0] - cx, part["position"][1] - cy,
part["position"][2]], list(at), 0.001)
sc = self.expect(f"{s} 1", *rows)
second_part(f"{s} 1", sc, (115, 60, 2.5))
reply = self.run("object_mirror", objects=[1], axis="x")
self.t.equal(f"{s} 2: the reply names second", named(reply), [(1, "second")])
self.inst(1).update(mirrored=True, at=(107.5, 60))
sc = self.expect(f"{s} 2: second mirrors about the centre of its box", *rows)
second_part(f"{s} 2", sc, (92.5, 60, 2.5))
self.run("object_transform", object=1, translate=[0, 0, 15], drop_to_bed=False)
self.inst(1)["z"] = 15
self.expect(f"{s} 3: an object of two parts stays above the bed", *rows)
self.run("object_transform", object=0, translate=[0, 0, 15], drop_to_bed=False)
self.expect(f"{s} 4: an object of one part left above the bed drops anyway", *rows)
reply = self.run("object_drop", objects=[1])
self.t.equal(f"{s} 5: the reply", (reply.get("moved"), named(reply)), (True, [(1, "second")]))
self.inst(1)["z"] = 0
self.expect(f"{s} 5", *rows)
reply = self.run("object_drop", objects=[1])
self.t.equal(f"{s} 6: a drop of what rests on the bed is not refused", reply.get("moved"), False)
self.expect(f"{s} 6", *rows)
self.run("object_transform", object=1, translate=[0, 0, 15], drop_to_bed=False)
self.run("object_select", objects=[1])
reply = self.run("object_drop")
self.t.equal(f"{s} 7: the reply's moved", reply.get("moved"), True)
self.expect(f"{s} 7: no target drops the selection", *rows)
for step in (8, 9):
reply = self.run("object_center", objects=[0, 2])
self.t.equal(f"{s} {step}: the reply's plates", reply.get("plates"),
[{"plate": 1, "objects": [0]}, {"plate": 2, "objects": [2]}])
self.inst(0)["at"] = self.inst(2)["at"] = (128, 128)
self.expect(f"{s} {step}: each goes to the centre of its own plate", *rows)
self.run("object_add_primitive", plate=1, name="fourth", position=self.corner(1, 128, 60), **CUBE)
self.add("fourth", I(1, (128, 60)))
self.expect(f"{s} 10", '"" 0 · "" 3 * · "" 1', "first@1 · second@1 · third@2 · fourth@1")
reply = self.run("object_center", objects=[0, 3], plate=0)
self.t.equal(f"{s} 11: the reply's plates", reply.get("plates"), [{"plate": 0, "objects": [0, 3]}])
self.inst(0).update(plate=0, at=(128, 162))
self.inst(3).update(plate=0, at=(128, 94))
self.expect(f"{s} 11: the two move as one group", '"" 2 · "" 1 * · "" 1',
"first@0 · second@1 · third@2 · fourth@0")
self.run("object_select", objects=[2])
reply = self.run("object_center")
self.t.equal(f"{s} 12: the reply's plates", reply.get("plates"), [{"plate": 1, "objects": [2]}])
self.inst(2).update(plate=1, at=(128, 128))
rows = '"" 2 · "" 2 * · "" 0', "first@0 · second@1 · third@1 · fourth@0"
self.expect(f"{s} 12: the selection goes to the centre of the current plate", *rows)
self.run("object_transform", object=2, rotate=[45, 0, 0], mode="absolute")
self.inst(2)["rot"] = [45, 0, 0]
sc = self.expect(f"{s} 13", *rows)
self.t.near(f"{s} 13: third's bbox.size z", sc[2]["instances"][0]["bbox"]["size"][2], 28.28, 0.01)
reply = self.run("object_auto_orient", objects=[1, 2])
self.t.equal(f"{s} 14: the reply's objects", named(reply), [(1, "second"), (2, "third")])
self.t.equal(f"{s} 14: the reply's rotations", [(r.get("object"), r.get("instance"))
for r in reply.get("rotations", [])], [(1, 0), (2, 0)])
self.inst(1)["rot"] = self.inst(2)["rot"] = None
sc = self.expect(f"{s} 14: naming objects turns no other", *rows)
third = sc[2]["instances"][0]
self.t.near(f"{s} 14: third lies on a face, rotation_deg x", third["rotation_deg"][0], 90, 0.1)
self.t.near(f"{s} 14: third lies on a face, bbox.size z", third["bbox"]["size"][2], 20, 0.01)
self.t.equal(f"{s} 14: selection() objects", selection(self.c)["objects"], [1, 2])
self.run("object_select", none=True)
self.run("object_transform", object=0, rotate=[0, 45, 0], mode="absolute")
reply = self.run("object_auto_orient")
rotations = {(r.get("object"), r.get("instance")): r.get("rotation_deg") for r in reply.get("rotations", [])}
self.t.equal(f"{s} 15: with nothing selected every object is oriented", sorted(rotations),
[(0, 0), (1, 0), (2, 0), (3, 0)])
for w in self.want:
w["inst"][0]["rot"] = None
sc = self.expect(f"{s} 15", *rows)
self.t.check(f"{s} 15: each rotation the reply gives is the instance's",
all(close(turn(rotations[(o["index"], 0)]), turn(o["instances"][0]["rotation_deg"]), 1e-6)
for o in sc if (o["index"], 0) in rotations), rotations)
self.t.near(f"{s} 15: first lies on a face, bbox.size z", sc[0]["instances"][0]["bbox"]["size"][2], 20, 0.01)
s_fit = 11.888
for step, name, index, plates_row in [(16, "fit", 4, '"" 2 · "" 3 * · "" 0'),
(17, "fit2", 5, '"" 2 · "" 4 * · "" 0')]:
at = (60, 200) if name == "fit" else (200, 60)
self.run("object_add_primitive", plate=1, name=name, position=self.corner(1, *at), **CUBE)
if name == "fit":
reply = self.run("object_scale_to_fit", objects=[index])
else:
self.run("object_select", objects=[index])
reply = self.run("object_scale_to_fit")
scales = reply.get("scales", [])
self.t.equal(f"{s} {step}: the reply's scales name {name}",
[(x.get("object"), x.get("instance")) for x in scales], [(index, 0)])
self.t.near(f"{s} {step}: the reply's scale", scales[0].get("scale") if scales else None, [s_fit] * 3,
0.001)
self.add(name, I(1, None, scale=[s_fit] * 3))
rows = plates_row, rows[1] + f" · {name}@1"
sc = self.expect(f"{s} {step}", *rows)
fit = sc[index]["instances"][0]
cx, cy = corner(self.c, 1)
self.t.near(f"{s} {step}: {name} fills the widest free part of the bed, at",
[fit["offset"][0] - cx, fit["offset"][1] - cy], [137, 128], 0.01)
self.size(f"{s} {step}: {name}'s", fit, [237.76] * 3, 0.02)
def arranging(self):
s = "arranging and filling the bed"
self.start(s)
for step, args in [(1, {}), (2, {"plates": 0})]:
self.refused(f"{s} {step}: an arrange with no objects is refused", "object_arrange",
code="no_objects_to_arrange", **args)
self.expect(f"{s} {step}", '"" 0 *', "")
for name in ("A", "B"):
self.run("object_add_primitive", name=name, position=self.corner(0, 128, 128), **CUBE)
self.run("object_select", none=True)
self.add("A", I(0, (128, 128)))
self.add("B", I(0, (128, 128)))
after3 = self.saved()
rows = '"" 2 *', "A@0 · B@0"
self.expect(f"{s} 3: one on the other", *rows, any_order=True)
def two(label, at_least=None, under=None):
sc = self.expect(label, *rows, any_order=True)
a, b = (square(self.find(sc, n)["instances"][0]) for n in ("A", "B"))
self.spread_on(label, 0, [a, b])
if at_least is not None:
self.t.check(f"{label}: the gap between A and B at least {at_least}", gap(a, b) >= at_least, gap(a, b))
if under is not None:
self.t.check(f"{label}: the gap between A and B under {under}", gap(a, b) < under, gap(a, b))
return sc
self.run("view_set", tab="preview")
reply = self.run("object_arrange")
self.t.equal(f"{s} 4: the reply's off_plate and plates", (reply.get("off_plate"), reply.get("plates")),
([], 1))
self.t.equal(f"{s} 4: an arrange shows the Prepare view", self.c.call("app_state").get("tab"), "prepare")
for w in self.want:
w["inst"][0]["at"] = None
two(f"{s} 4")
self.undo()
self.want = copy.deepcopy(after3)
self.expect(f"{s} 5: the arrange was one undo step", *rows, any_order=True)
for w in self.want:
w["inst"][0]["at"] = None
reply = self.run("object_arrange", plates=0, spacing=30, rotate=False, align_y=False)
settings = reply.get("settings", {})
self.t.equal(f"{s} 6: the reply's settings and off_plate", (settings.get("spacing"), settings.get("rotate"),
settings.get("align_y"), reply.get("off_plate")), (30, False, False, []))
sc = two(f"{s} 6", at_least=29.9)
for name in ("A", "B"):
self.run("object_transform", object=self.find(sc, name)["index"], position=self.corner(0, 128, 128))
reply = self.run("object_arrange")
self.t.equal(f"{s} 7: the arrange options panel kept the spacing", reply.get("settings", {}).get("spacing"), 30)
two(f"{s} 7", at_least=29.9)
reply = self.run("object_arrange", plates=0, spacing=10)
self.t.equal(f"{s} 8: the reply's spacing", reply.get("settings", {}).get("spacing"), 10)
sc = two(f"{s} 8: the spacing decides how far apart they go", at_least=9.9, under=29.9)
self.run("plate_add")
self.refused(f"{s} 9: an arrange of an empty plate is refused", "object_arrange",
words="Plate 1 has no objects to arrange", plates=1)
self.expect(f"{s} 9", '"" 2 · "" 0 *', rows[1], any_order=True)
self.run("object_transform", object=self.find(sc, "A")["index"], position=self.corner(0, 60, 60))
self.run("object_transform", object=self.find(sc, "B")["index"], position=self.corner(0, 180, 180))
self.run("object_add_primitive", name="C", plate=1, position=self.corner(1, 128, 128), **CUBE)
self.by_name("A")["inst"] = [I(0, (60, 60))]
self.by_name("B")["inst"] = [I(0, (180, 180))]
self.add("C", I(1, (128, 128)))
rows = '"" 2 · "" 1 *', "A@0 · B@0 · C@1"
sc = self.expect(f"{s} 10", *rows, any_order=True)
self.refused(f"{s} 11: a plate the project lacks is refused", "object_arrange",
words="Plate 7 does not exist (the project has plates 0..1)", plates=7)
self.expect(f"{s} 11", *rows, any_order=True)
self.refused(f"{s} 12: fill_object with plates is refused", "object_arrange",
words="fill_object fills the object's own plate", fill_object=0, plates=0)
self.expect(f"{s} 12", *rows, any_order=True)
self.run("object_set_instances", object=self.find(sc, "C")["index"], count=3)
reply = self.run("object_arrange", plates=1, spacing=10, rotate=False)
settings = reply.get("settings", {})
self.t.equal(f"{s} 13: the reply's settings", (settings.get("spacing"), settings.get("rotate")), (10, False))
self.by_name("C")["inst"] = [I(1) for _ in range(3)]
after13 = self.saved()
rows = '"" 2 · "" 1 *', "A@0 · B@0 · C@1×3"
sc = self.expect(f"{s} 13: arranging one plate leaves the other plates' objects", *rows, any_order=True)
self.spread_on(f"{s} 13: C", 1, self.squares(sc, 1))
self.run("object_arrange", plates=0)
self.by_name("A")["inst"] = [I(0)]
self.by_name("B")["inst"] = [I(0)]
rows = '"" 2 * · "" 1', rows[1]
sc = self.expect(f"{s} 14: the plate arranged is made current", *rows, any_order=True)
self.spread_on(f"{s} 14: A and B", 0, self.squares(sc, 0))
self.t.check(f"{s} 14: C's three inside plate 1",
all(inside(q, rect(self.c, 1)) for q in self.squares(sc, 1)), self.squares(sc, 1))
self.run("object_transform", object=self.find(sc, "A")["index"], position=self.corner(0, 60, 60))
self.run("object_transform", object=self.find(sc, "B")["index"], position=self.corner(0, 180, 180))
a = self.find(sc, "A")["index"]
reply = self.run("object_arrange", fill_object=a)
sc = scene(self.c)
n = len(self.find(sc, "A")["instances"])
self.t.check(f"{s} 15: A has at least 2 instances", n >= 2, n)
self.t.equal(f"{s} 15: the reply", {k: reply.get(k) for k in ("object", "filled_with", "added", "instances",
"plate", "off_plate")},
{"object": a, "filled_with": "instances", "added": n - 1, "instances": n, "plate": 0,
"off_plate": []})
self.by_name("A")["inst"] = [I(0) for _ in range(n)]
self.by_name("B")["inst"] = [I(0, (180, 180))]
sc = self.expect(f"{s} 15: Fill bed adds to its object alone, and moves no other", rows[0],
f"A@0×{n} · B@0 · C@1×3", any_order=True)
self.spread_on(f"{s} 15: plate 0", 0, self.squares(sc, 0))
self.undo()
self.want = after13
sc = self.expect(f"{s} 16: Fill bed was one undo step", rows[0], "A@0 · B@0 · C@1×3", any_order=True)
c = self.find(sc, "C")["index"]
reply = self.run("object_arrange", fill_object=c)
sc = scene(self.c)
m = len(self.find(sc, "C")["instances"])
self.t.check(f"{s} 17: C has at least 4 instances", m >= 4, m)
self.t.equal(f"{s} 17: the reply", {k: reply.get(k) for k in ("plate", "added", "instances")},
{"plate": 1, "added": m - 3, "instances": m})
self.by_name("C")["inst"] = [I(1) for _ in range(m)]
sc = self.expect(f"{s} 17: an object on another plate fills its own plate, made current", '"" 2 · "" 1 *',
f"A@0 · B@0 · C@1×{m}", any_order=True)
self.spread_on(f"{s} 17: C", 1, self.squares(sc, 1))
def cloning(self):
s = "cloning"
self.start(s)
self.run("object_select", none=True)
self.run("object_add_primitive", name="cube", position=self.corner(0, 60, 60), **CUBE)
self.add("cube", I(0, (60, 60)))
after0 = self.saved()
reply = self.run("object_clone", objects=[0], arrange=False)
copied = reply.get("copied", {})
self.t.equal(f"{s} 1: the reply", (named(reply), sorted(copied), named(copied), reply.get("object_count"),
reply.get("arranged")),
([(1, "cube")], ["objects"], [(0, "cube")], 2, False))
self.add("cube", I(0))
sc = self.expect(f"{s} 1: without an arrange the source stays", '"" 2 *', "cube@0 · cube@0")
self.spread_on(f"{s} 1", 0, self.squares(sc, 0))
self.t.equal(f"{s} 1: selection() objects", selection(self.c)["objects"], [1])
self.undo()
self.want = copy.deepcopy(after0)
self.expect(f"{s} 2", '"" 1 *', "cube@0")
reply = self.run("object_clone", objects=[0], count=3, arrange=True)
self.t.equal(f"{s} 3: the reply", (named(reply), reply.get("object_count"), reply.get("arranged")),
([(1, "cube"), (2, "cube"), (3, "cube")], 4, True))
self.want = [{"name": "cube", "auto_drop": True, "inst": [I(0)]} for _ in range(4)]
sc = self.expect(f"{s} 3", '"" 4 *', "cube@0 · cube@0 · cube@0 · cube@0")
self.spread_on(f"{s} 3", 0, self.squares(sc, 0))
self.undo()
self.inst(0)["at"] = (60, 60)
self.expect(f"{s} 4: the arrangement is an undo step of its own", '"" 4 *',
"cube@0 · cube@0 · cube@0 · cube@0")
self.undo()
self.want = copy.deepcopy(after0)
self.expect(f"{s} 5: the copies were one undo step", '"" 1 *', "cube@0")
self.run("view_set", camera="iso")
self.run("view_set", camera="fit_objects")
self.run("object_select", objects=[0])
wait(self.c, "idle")
reply = self.c.call("mouse_gesture", at={"object": 0, "spot": "top"}, button="right", popup_item="Clone")
self.t.equal(f"{s} 6: the gesture ran", reply.get("ran"), "Clone")
wait(self.c, "dialog")
self.t.equal(f"{s} 6: the dialog that opens", [d.get("title") for d in self.c.call("app_state")["dialogs"]],
["Clone"])
# The dialog stays open, its fields disabled, while it clones and arranges, and the answer's job follows that.
self.c.await_job(self.c.call("dialog_answer", dialog={"title": "Clone"}, button="OK"))
wait(self.c, "idle")
self.t.equal(f"{s} 6: no dialog open afterwards", self.c.call("app_state").get("dialogs"), [])
self.want = [{"name": "cube", "auto_drop": True, "inst": [I(0)]} for _ in range(2)]
sc = self.expect(f"{s} 6", '"" 2 *', "cube@0 · cube@0")
self.spread_on(f"{s} 6", 0, self.squares(sc, 0))
self.run("object_set_instances", object=0, count=2)
self.run("object_select", instances=[[0, 1]])
reply = self.run("object_clone", arrange=False)
copied = reply.get("copied", {})
self.t.equal(f"{s} 7: the reply", ([(i.get("object"), i.get("instance")) for i in copied.get("instances", [])],
"objects" in copied, named(reply), reply.get("object_count")),
([(0, 1)], False, [(2, "cube")], 3))
self.want[0]["inst"].append(I(0))
self.add("cube", I(0))
self.expect(f"{s} 7: a selected instance is copied as a new object of one instance", '"" 3 *',
"cube@0×2 · cube@0 · cube@0")
def printable(self):
s = "leaving instances out of the print"
self.start(s)
self.run("object_select", none=True)
self.run("object_add_primitive", shape="cube", size=[10, 10, 10], name="a", position=self.corner(0, 60, 60))
self.run("object_set_instances", object=0, count=3)
self.run("object_select", none=True)
self.run("object_add_primitive", shape="cube", size=[15, 15, 15], name="b", position=self.corner(0, 180, 60))
self.add("a", I(0, (60, 60)), I(0, (72.8, 72.8)), I(0, (85.6, 85.6)))
self.add("b", I(0, (180, 60)))
after1 = self.saved()
rows = '"" 2 *', "a@0×3 · b@0"
def sliced(label, step, a_copies):
reply = self.run("plate_slice", plates=0)
self.t.equal(f"{label}: the slice", [p.get("outcome") for p in reply.get("plates", [])], ["ok"])
path = os.path.join(self.folder, f"printable-{step}.gcode")
self.run("project_export", format="gcode", path=path, overwrite=True)
self.t.equal(f"{label}: the G-code prints a in {a_copies} copies and b in 1", sorted(gcode_prints(path)),
[("a", a_copies), ("b", 1)])
self.expect(f"{s} 1", *rows)
sliced(f"{s} 1", 1, 3)
reply = self.run("object_set_printable", instances=[[0, 1]], printable=False)
self.t.equal(f"{s} 2: the reply", ([(i.get("object"), i.get("instance"), i.get("printable"))
for i in reply.get("instances", [])], "objects" in reply),
([(0, 1, False)], False))
self.inst(0, 1)["printable"] = False
self.expect(f"{s} 2", *rows)
sliced(f"{s} 3: an instance that is not printable is left out of the G-code", 3, 2)
self.expect(f"{s} 3", *rows)
self.undo()
self.want = after1
self.expect(f"{s} 4: Printable was one undo step", *rows)
reply = self.run("object_set_printable", objects=[0], printable=False)
self.t.equal(f"{s} 5: the reply", ([(i.get("object"), i.get("instance"), i.get("printable"))
for i in reply.get("instances", [])], named(reply)),
([(0, 0, False), (0, 1, False), (0, 2, False)], [(0, "a")]))
for inst in self.want[0]["inst"]:
inst["printable"] = False
self.expect(f"{s} 5: an object sets every instance of its own and no other's", *rows)
def kept(self):
s = "what the project keeps"
self.start(s)
self.run("plate_add")
self.run("object_add_primitive", plate=0, name="kept", position=self.corner(0, 60, 60), **CUBE)
self.run("object_set_instances", object=0, count=2)
self.run("object_transform", object=0, instance=0, rotate=[0, 0, 30], mode="absolute")
self.run("object_transform", object=0, instance=1, scale=1.5)
self.run("object_select", instances=[[0, 1]])
self.run("object_mirror", axis="x")
self.run("object_set_printable", instances=[[0, 1]], printable=False)
self.add("kept", I(0, (60, 60), rot=None, mirrored=True),
I(0, (72.8, 72.8), scale=[1.5] * 3, mirrored=True, printable=False))
def turned(label, sc):
self.size(f"{label}: kept's instance 0, turned 30 degrees,", sc[0]["instances"][0],
[20 * (math.cos(math.radians(30)) + math.sin(math.radians(30)))] * 2 + [20])
turned(f"{s} 1", self.expect(f"{s} 1: Mirror of the selected instance mirrors the object's other one",
'"" 1 * · "" 0', "kept@0×2"))
self.run("object_add_primitive", plate=1, name="lifted", position=self.corner(1, 60, 60), **CUBE)
self.run("object_set_auto_drop", objects=[1], auto_drop=False)
self.run("object_transform", object=1, translate=[0, 0, 15])
self.add("lifted", I(1, (60, 60), z=15), auto_drop=False)
rows = "kept@0×2 · lifted@1"
turned(f"{s} 2", self.expect(f"{s} 2", '"" 1 · "" 1 *', rows))
path = os.path.join(self.folder, "kept.3mf")
self.run("project_save", path=path, overwrite=True)
self.run("project_new", discard_changes=True)
self.empty(f"{s} 3: after project_new")
self.run("project_open", path=path)
wait(self.c, "idle")
turned(f"{s} 3", self.expect(f"{s} 3: the project file keeps them; opening it makes plate 0 current",
'"" 1 * · "" 1', rows))
def run_all(self, only=()):
scenarios = [("adding a shape", self.adding), ("moving an instance", self.moving),
("moving a part", self.moving_a_part), ("the number of instances", self.instances),
("placing objects", self.placing), ("arranging and filling the bed", self.arranging),
("cloning", self.cloning), ("leaving instances out of the print", self.printable),
("what the project keeps", self.kept)]
for name, scenario in scenarios:
if not only or scenario.__name__ in only:
self.t.scenario(name, scenario)
self.run("project_new", discard_changes=True)
return self.t.exit_code()
def main():
client, _ = orca_mcp.session_client()
with tempfile.TemporaryDirectory(prefix="orca-objects-") as folder:
return ObjectsTest(client, folder).run_all(sys.argv[1:])
if __name__ == "__main__":
sys.exit(main())
+9 -1
View File
@@ -108,11 +108,19 @@ def main():
check("and the arrangement moved a cube", offsets() != before, (before, offsets()))
check("and the Prepare view is shown afterwards", state["selection"].get("canvas") == "3d", state["selection"])
client.call("view_set", canvas="3d")
# Both cubes on one spot, so that only an arrangement that runs can set them apart.
for i in range(2):
client.call("object_transform", object=i, position=[128, 128, 10])
together = offsets()
check("the cubes are back on one spot", together == [[128, 128], [128, 128]], together)
client.call("object_select", objects=[0])
opened = client.call("widget_click", target={"gizmo": "Move"})
code, reply = answer("object_arrange")
state = client.call("app_state")
check("object_arrange arranges with the Move gizmo open", opened.get("active") is True and code is None, (opened, reply))
after = offsets()
apart = len(after) == 2 and (abs(after[0][0] - after[1][0]) >= 20 or abs(after[0][1] - after[1][1]) >= 20)
check("object_arrange arranges with the Move gizmo open", opened.get("active") is True and code is None and apart,
(opened, reply, after))
check("and the gizmo stays open", state.get("gizmo") is not None, state.get("gizmo"))
if state.get("gizmo") is not None:
client.call("widget_click", target={"gizmo": "Move"})
+15 -1
View File
@@ -15,7 +15,8 @@ command's name, chaining the original, and returns the command's whole reply. se
datadir's login in its own token file, opens its main window 1600 x 900 at the top left of the work area, and leaves
a reused datadir's conf as it is. ORCA_MCP_CALL_LOG gets a line
per call, and reply_budget_s() reads ORCA_MCP_REPLY_BUDGET_MS as the app does. Exits 0 when every check passes.
The folders the checks make are removed when they end.
The folders the checks make are removed when they end. The checks are asserts, so a Python that runs with its
asserts off (-O, or PYTHONOPTIMIZE, which the sweep's runner passes on) fails the test before any of them.
"""
import http.server
@@ -43,6 +44,17 @@ def ok(name):
print(f"ok - {name}")
def asserts_live():
"""Whether Python runs the asserts every other check is, printing the check's line: with them off every check
would pass without checking anything."""
if sys.flags.optimize > 0:
print(f"FAIL - the asserts are live: Python runs with its asserts off (optimize level {sys.flags.optimize}, "
"from -O or PYTHONOPTIMIZE)")
return False
ok("the asserts are live")
return True
def same_path(a, b):
return os.path.normcase(os.path.normpath(a)) == os.path.normcase(os.path.normpath(b))
@@ -306,6 +318,8 @@ def check_seed_datadir():
def main():
global _ROOT
if not asserts_live():
return 1
with tempfile.TemporaryDirectory(prefix="orca-attach-") as root:
_ROOT = root
check_seed_datadir()
+13 -1
View File
@@ -14,7 +14,8 @@ and silent is refused. view_set's tab refusal is the operation's, with its code.
Picks from the Speed Dial, opened with Space on the 3D view and searched by title as a person types: View: Top turns
the camera, Deselect All on the Preview tab clears the Prepare selection without leaving the tab, and Go to layer takes
its percentage from the second phase. None of them starts a job or shows a notice.
its percentage from the second phase. None of them starts a job or shows a notice, while a pick of Slice and Preview,
the last one, made the same way on the same project, does both.
Auto-Arrange and Select All Objects, on a plate of three cubes: object_arrange {} and action_run of its action wait
and reply as the command does (the settings in force, what was left off the plates); the journal keeps the call with
@@ -336,6 +337,17 @@ def main():
state.get("selection"))
client.call("view_set", canvas="3d")
# The control for the absences above: a pick of Slice and Preview, opened and searched the same way on the same
# project, starts its slice as a job, listed under its command and announced as Started, then Finished.
since = last_job()
dial_pick("Slice and Preview")
state = settled()
jobs = [j for j in state.get("jobs", []) if int(j["id"][1:]) > since and j.get("tool") == "plate_slice"]
check("a pick that runs as a job is listed as one", jobs != [], state.get("jobs"))
notes = [n["text"] for n in state.get("notifications", []) if "Started" in n.get("text", "") or "Finished" in n.get("text", "")]
check("and shows its Started or Finished notice", notes != [], state.get("notifications"))
client.call("view_set", tab="prepare")
client.call("project_new", discard_changes=True)
failed = [c for c in checks if not c[1]]
for name, ok, detail in checks:
+5 -3
View File
@@ -144,10 +144,8 @@ def wait_for(predicate, timeout):
def run(orca, datadir, scratch):
fields = {"key", "name", "version", "installed", "enabled", "status", "source", "capabilities", "error"}
before = rows(orca)
check("plugin_list lists the plugins with their fields", isinstance(before, list) and all(
{"key", "name", "version", "installed", "enabled", "status", "source", "capabilities", "error"} <= set(r) for r in before),
before)
check("no fixture plugin is installed yet", all(r["name"] not in (INSTALLED, SIDE_LOADED) for r in before), before)
# --- plugin_install_local, and again with and without overwrite ---
@@ -157,6 +155,10 @@ def run(orca, datadir, scratch):
check("plugin_install_local installs the fixture", installed.get("level") == "success", installed)
row = row_named(orca, INSTALLED)
check("plugin_list finds it, installed", row is not None and row["installed"] and row["source"] == "local", row)
# Read on the fixture's row, since a fresh folder lists no plugin before the install; the rows listed then, if any,
# are held to the same fields.
check("plugin_list lists the plugins with their fields", row is not None and fields <= set(row)
and isinstance(before, list) and all(fields <= set(r) for r in before), (row, before))
if row is None:
return
key = row["key"]
+43 -15
View File
@@ -1,6 +1,6 @@
"""Checks a plugin's calls into the MCP tools and the operations it offers, in the running app.
Launches OrcaSlicer on a fresh data folder with the Design tab on (in a build with CAD) and
Launches OrcaSlicer on a fresh data folder with the Design tab on (--cad) and
tests/plugins/mcp_tools_fixture side-loaded, and tests/plugins/mcp_tools_broken, whose load fails after declaring an
operation: over MCP, then once without MCP, running a replay with --run, so the plugin's calls go to the
runtime started without its endpoint. The first launch also checks that the plugin is sent the NewProject event when
@@ -83,6 +83,15 @@ def lines_of(path):
return 0
def canvas_height(orca):
"""The height of the 3D view as widget_list gives it (its canvas "OrcaSceneCanvas" line), or None."""
_, texts = orca.call_with_text("widget_list", include_menus=False, include_imgui=False, include_web=False)
for line in "\n".join(texts).splitlines():
if 'canvas "OrcaSceneCanvas"' in line:
return int(line.rsplit("x", 1)[1])
return None
def harness(env, *args):
return subprocess.run([sys.executable, os.path.join(HERE, "orca_mcp.py"), *args], env=env, capture_output=True, text=True,
timeout=300)
@@ -125,7 +134,7 @@ def main():
# --- Over MCP: the plugin's operation and its tool calls, beside a plugin whose load fails. ---
plugin_dir = install(datadir)
install_broken(datadir)
# The Design tab on, so that its commands are among tool_search's commands; a build without CAD has none.
# The Design tab on, so that its commands are among tool_search's commands.
orca = launch(env, datadir, ["--cad", *extra])
described = orca.call_raw("tool_search", {"tool": f"plugin.{PLUGIN}.measure"})
check("tool_search describes the plugin's operation", not described.get("isError") and
@@ -142,6 +151,9 @@ def main():
check("a plugin calls a tool from its Script worker", called == {"ok": True, "result": True}, called)
threaded = run_plugin_script(orca, plugin_dir, "thread", CAPABILITIES[1])
check("a thread its Script worker starts calls a tool too", threaded == {"ok": True, "result": True}, threaded)
# The agent's own dialog_auto_answer, which clears only the rules MCP clients set: the journal keeps this call,
# the control for the plugin's call of the same tool, which it must not keep.
orca.call("dialog_auto_answer", rules=[])
rule = run_plugin_script(orca, plugin_dir, "rule", CAPABILITIES[2])
check("an auto-answer rule a plugin sets is owned by the plugin", rule == {"ok": True, "result": "plugin"}, rule)
exported = run_plugin_script(orca, plugin_dir, "export", CAPABILITIES[3])
@@ -178,29 +190,42 @@ def main():
unknown = orca.call_raw("tool_search", {"group": "commandz"})
check("a group no command has is refused, naming the groups there are",
unknown.get("isError") and "Objects" in unknown["content"][0]["text"], unknown)
# It shows the Run Script panel; the second call hides it again.
# It shows the Run Script panel, which docks under the 3D view and so makes it shorter; the second call hides it
# again. The panel is kept from automation, so widget_list reads the 3D view instead.
orca.call("view_set", tab="prepare")
shown_before = canvas_height(orca)
ran = orca.call_raw("tool_call", {"tool": "script_toggle_panel"})
check("tool_call runs a menu item's command", not ran.get("isError"), ran)
orca.call("app_wait", **{"for": "idle"})
shown_after = canvas_height(orca)
check("tool_call runs a menu item's command", not ran.get("isError") and shown_before is not None
and shown_after is not None and shown_after < shown_before, (ran, shown_before, shown_after))
orca.call_raw("tool_call", {"tool": "script_toggle_panel"})
orca.call("app_wait", **{"for": "idle"})
hidden_after = canvas_height(orca)
check("and a second call hides it", shown_after is not None and hidden_after is not None and hidden_after > shown_after,
(shown_after, hidden_after))
found = orca.call("tool_search", query="mesh normals")
check("tool_search's search finds the Python API", found.get("python", {}).get("items", [{}])[0].get("name") ==
"orca.host.TriangleMesh.face_normals", found)
design_tab = orca.call("app_state").get("design_tab")
check("the Design tab is on (launch --cad)", design_tab is True, design_tab)
found = orca.call("tool_search", query="extrude")
if orca.call("app_state").get("design_tab"):
extrude = next((i for i in found["items"] if i["name"] == "extrude"), {})
check("tool_search's search finds a Design command among the commands, with its schema",
extrude.get("group") == "Design" and extrude.get("listed") is False and "input_schema" in extrude, found)
else:
check("without the Design tab, tool_search's search finds no Design command",
not any(i.get("group") == "Design" for i in found["items"]), found)
extrude = next((i for i in found["items"] if i["name"] == "extrude"), {})
check("tool_search's search finds a Design command among the commands, with its schema",
extrude.get("group") == "Design" and extrude.get("listed") is False and "input_schema" in extrude, found)
check("and in no section of its own", "cad" not in found, found)
found = orca.call("tool_search", query="?")
check("a query with no words to search for matches nothing", found.get("total") == 0 and "names" not in found, found)
journal = orca.call("replay_export")["replay"]["steps"]
check("a plugin's calls are not in the agent's journal", not any(s["tool"] == "dialog_auto_answer" for s in journal),
journal)
answers = [s for s in journal if s["tool"] == "dialog_auto_answer"]
check("a plugin's calls are not in the agent's journal",
len(answers) == 1 and answers[0].get("args", {}).get("rules") == [], answers)
broken_row = next((r for r in orca.call("plugin_list")["plugins"] if r["key"] == BROKEN), None)
check("the plugin whose load failed is listed with its error",
broken_row is not None and "this fixture's load fails here on purpose" in (broken_row.get("error") or ""), broken_row)
broken = orca.call_raw("tool_search", {"tool": f"plugin.{BROKEN}.measure"})
check("a plugin whose load failed offers none of its operations", broken.get("isError"), broken)
check("and offers none of its operations", broken.get("isError") is True and
broken["content"][0]["text"].startswith(f"Unknown tool: plugin.{BROKEN}.measure"), broken)
# A project started by project_new or by its Speed Dial action tells plugins, as File > New Project does.
started = lambda: lines_of(os.path.join(plugin_dir, "new_projects.txt"))
before = started()
@@ -209,7 +234,10 @@ def main():
orca.call("action_run", id="orca_command:new_project:orca")
check("and so does its action, new_project", wait_for(lambda: started() == before + 2, 10), started())
held = run_plugin_script(orca, plugin_dir, "handle", CAPABILITIES[4])
check("the plugin opens a progress dialog and keeps its handle", held.get("ok") is True, held)
# The script gives create_progress_dialog this title.
titles = [w.get("title") for w in orca.call("window_list").get("items", [])]
check("the plugin opens a progress dialog and keeps its handle", held.get("ok") is True and "MCP tools fixture" in titles,
(held, titles))
grab = orca.await_job(orca.call("script_run", code=GRAB_HANDLE))
check("a script that finds a plugin's handle can use its methods", grab.get("result") is True, grab)
+3 -2
View File
@@ -289,13 +289,14 @@ def main():
except McpError:
return None
shown = wait_for(lambda: panel() not in (None, "none"), 20)
# The page shows the panel with jQuery's show(), which leaves its display "block" (home.js).
shown = wait_for(lambda: panel() == "block", 20)
check("the Home page shows its login side panel", shown, panel())
client.call("preferences_set", values={"hide_login_side_panel": True})
hidden = wait_for(lambda: panel() == "none", 10)
check("preferences_set hide_login_side_panel true hides it at once, without the dialog", hidden, panel())
client.call("preferences_set", values={"hide_login_side_panel": False})
shown_again = wait_for(lambda: panel() not in (None, "none"), 10)
shown_again = wait_for(lambda: panel() == "block", 10)
check("and false shows it again", shown_again, panel())
client.call("view_set", tab="prepare")
File diff suppressed because it is too large. Load diff
+516
View File
@@ -0,0 +1,516 @@
#!/usr/bin/env python3
"""Recordings, as the test_recording entry of tools/mcp/test-entries/gui_tools.md designs them.
tools/mcp/orca_mcp.py launch
tools/mcp/test_recording.py [--out DIR]
recording_start, recording_stop and recording_encode: a recording made while the GUI is driven, its report and its
file; a recording a nested replay_run starts and never stops, which the replay's end closes; overlays and the time
limit; and encoding asked for at the start, run as a job by the stop, deleting or keeping the .mkv. The recordings
are read back from their files. What the machine's ffmpeg can encode decides each encode's checks: an encode it
cannot make must be refused with the app's reason, and the file checks it would have had print as SKIP. The last
line names what could be encoded. The recordings go to --out, else to a new temporary folder.
"""
import argparse
import os
import shutil
import struct
import subprocess
import sys
import tempfile
import time
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import orca_mcp # noqa: E402
from checks import Checks, plates, run, wait # noqa: E402
REPO = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__))))
CUBE = os.path.join(REPO, "resources", "handy_models", "OrcaCube_v2.drc")
PREFERENCES = "orca_command:open_preferences:orca"
class RecordingChecks(Checks):
"""Checks that can also be skipped: a skipped check prints `SKIP <name>: <why>` and is not counted."""
def __init__(self):
super().__init__()
self.skipped = 0
def skip(self, name, why):
self.skipped += 1
print(f"SKIP {name}: {why}", flush=True)
# ---- Reading the files ----
def _vint(data, pos, marker):
"""An EBML variable-length integer at `pos`: (value, length, all value bits set). An element id keeps its
length marker (`marker`); a size drops it."""
first, length, mask = data[pos], 1, 0x80
while length <= 8 and not first & mask:
length, mask = length + 1, mask >> 1
value = first if marker else first & (mask - 1)
for i in range(1, length):
value = (value << 8) | data[pos + i]
return value, length, not marker and value == (1 << (7 * length)) - 1
SEGMENT, INFO, TRACKS, TRACK, VIDEO, CLUSTER, GROUP = 0x18538067, 0x1549A966, 0x1654AE6B, 0xAE, 0xE0, 0x1F43B675, 0xA0
MASTERS = {SEGMENT, INFO, TRACKS, TRACK, VIDEO, CLUSTER}
def mkv(path):
"""A Matroska file as the app writes it: {codec, width, height, frame_ms (the default frame duration), blocks,
seconds (the segment's duration)}."""
with open(path, "rb") as f:
data = f.read()
found = {"blocks": 0}
def uint(body, size):
return int.from_bytes(data[body:body + size], "big")
def walk(pos, end):
while pos < end:
eid, n1, _ = _vint(data, pos, True)
size, n2, unknown = _vint(data, pos + n1, False)
body = pos + n1 + n2
stop = end if unknown else min(end, body + size)
if eid in MASTERS:
walk(body, stop)
elif eid in (0xA3, GROUP): # a SimpleBlock or a BlockGroup: one frame
found["blocks"] += 1
elif eid == 0x86:
found["codec"] = data[body:stop].decode("ascii", "replace")
elif eid == 0xB0:
found["width"] = uint(body, size)
elif eid == 0xBA:
found["height"] = uint(body, size)
elif eid == 0x23E383:
found["frame_ms"] = uint(body, size) / 1e6
elif eid == 0x2AD7B1:
found["scale"] = uint(body, size)
elif eid == 0x4489:
found["duration"] = struct.unpack(">f" if size == 4 else ">d", data[body:stop])[0]
pos = stop
walk(0, len(data))
seconds = found.pop("duration", 0) * found.pop("scale", 1000000) / 1e9
return {**found, "seconds": seconds}
def mp4(path):
"""An MP4's first sample entry (hvc1 for H.265, avc1 for H.264) and its movie header's duration in seconds."""
with open(path, "rb") as f:
data = f.read()
found = {}
def walk(pos, end):
while pos + 8 <= end:
size, kind = struct.unpack(">I4s", data[pos:pos + 8])
head = 8
if size == 1:
size, head = struct.unpack(">Q", data[pos + 8:pos + 16])[0], 16
elif size == 0:
size = end - pos
body, stop = pos + head, pos + size
if kind in (b"moov", b"trak", b"mdia", b"minf", b"stbl"):
walk(body, stop)
elif kind == b"mvhd":
version = data[body]
if version == 1:
scale, duration = struct.unpack(">IQ", data[body + 20:body + 32])
else:
scale, duration = struct.unpack(">II", data[body + 12:body + 20])
found["seconds"] = duration / scale
elif kind == b"stsd" and "entry" not in found:
found["entry"] = data[body + 12:body + 16].decode("ascii", "replace")
pos = stop
walk(0, len(data))
return found
def fitted(w, h):
"""The video size the app makes of a w x h capture: scaled down so its longer side is at most 1920, then each
side rounded down to even (video_size())."""
scale = 1920 / max(w, h) if max(w, h) > 1920 else 1.0
return max(2, int(w * scale) & ~1), max(2, int(h * scale) & ~1)
def ffmpeg():
"""(path, encoders, why): the ffmpeg the app finds, the encoders it lists, and, when there is none, the reason
the app gives."""
env = os.environ.get("ORCA_FFMPEG")
if env:
if not os.path.isfile(env):
return None, set(), f"ORCA_FFMPEG names {env}, which is not a file"
path = env
else:
path = shutil.which("ffmpeg")
if not path and sys.platform == "darwin":
path = next((p for p in ("/opt/homebrew/bin/ffmpeg", "/usr/local/bin/ffmpeg", "/opt/local/bin/ffmpeg")
if os.path.isfile(p)), None)
if not path:
return None, set(), "ffmpeg was not found"
try:
out = subprocess.run([path, "-hide_banner", "-encoders"], capture_output=True, text=True, timeout=30).stdout
except (OSError, subprocess.SubprocessError):
out = ""
encoders = {line.split()[1] for line in out.splitlines() if len(line.split()) > 1 and line.startswith(" V")}
return path, encoders, None
class RecordingTest:
def __init__(self, client, folder):
self.c = client
self.t = RecordingChecks()
self.folder = folder
self.ffmpeg, self.encoders, self.no_ffmpeg = ffmpeg()
self.encoded = {}
def out(self, name):
return os.path.join(self.folder, name)
# ---- Calls and reads ----
def run(self, tool, **args):
return run(self.c, tool, **args)
def recording(self):
return self.c.call("app_state").get("recording")
def recording_is(self, label, path=None):
rec = self.recording()
if path is None:
self.t.equal(f"{label}: no recording runs", rec, None)
else:
self.t.equal(f"{label}: the recording that runs", os.path.normpath((rec or {}).get("path", "")),
os.path.normpath(path))
return rec
def capture(self, target):
reply = self.c.call("window_screenshot", target=target, include_image=False,
save_path=self.out(f"capture_{target}.png"), overwrite=True)
return reply["width"], reply["height"]
def same_path(self, label, got, want):
self.t.equal(label, os.path.normpath(got or ""), os.path.normpath(want))
def start(self, name):
self.run("project_new", discard_changes=True)
self.run("view_set", tab="prepare")
wait(self.c, "idle")
self.recording_is(f"{name}: the start")
self.t.equal(f"{name}: the start: the plates", plates(self.c),
[{"name": "", "current": True, "locked": False, "objects": 0}])
def can_encode(self, encoder):
"""Why an encode with `encoder` cannot be made on this machine, or None when it can."""
if self.no_ffmpeg:
return self.no_ffmpeg
if encoder not in self.encoders:
return f"ffmpeg has no {encoder}"
return None
def encode_refused(self, label, encoder, call):
"""The refusal an encode gets on a machine that cannot make it: the app's reason when ffmpeg is missing,
or that ffmpeg has no `encoder`."""
words = self.no_ffmpeg if self.no_ffmpeg else f"has no {encoder} encoder"
self.t.refused(f"{label}: the encode is refused", call, words=words)
def mkv_holds(self, label, path, size, frame_ms, written, seconds=None):
info = mkv(path)
self.t.equal(f"{label}: the file's codec", info.get("codec"), "V_MJPEG")
self.t.equal(f"{label}: the file's size", (info.get("width"), info.get("height")), size)
self.t.near(f"{label}: the file's frame duration", info.get("frame_ms"), frame_ms, 0.001)
self.t.check(f"{label}: the file holds the frames written, or one more",
info["blocks"] in (written, written + 1), (info["blocks"], written))
if seconds is not None:
self.t.near(f"{label}: the file's duration", info["seconds"], seconds, 0.1)
return info
# ---- Scenarios ----
def driven(self):
s = "a recording while the GUI is driven"
self.start(s)
main = fitted(*self.capture("main"))
session = self.out("session.mkv")
reply = self.run("recording_start", save_path=session, overwrite=True, captions=True, pointer=True)
self.same_path(f"{s} 1: the reply's path", reply.get("path"), session)
self.t.equal(f"{s} 1: the reply", {k: reply.get(k) for k in ("target", "fps", "captions", "pointer",
"max_seconds")},
{"target": "main", "fps": 10, "captions": True, "pointer": True, "max_seconds": 3600})
self.t.equal(f"{s} 1: the video's size", (reply.get("width"), reply.get("height")), main)
rec = self.recording_is(f"{s} 1", session)
self.t.equal(f"{s} 1: the recording's target", (rec or {}).get("target"), "main")
reply = self.run("project_import", paths=[CUBE])
wait(self.c, "idle")
self.t.equal(f"{s} 2: the reply's added", reply.get("added"), 1)
self.t.equal(f"{s} 2: one object", self.c.call("object_list")["total"], 1)
self.t.equal(f"{s} 2: an import selects what it adds", self.selected(), [0])
self.run("mouse_gesture", action="click", x=300, y=200)
self.t.equal(f"{s} 3: a click on empty space deselects", self.selected(), [])
self.run("mouse_gesture", action="click", at={"object": 0, "spot": "top"})
self.t.equal(f"{s} 4: a click on the object selects it", self.selected(), [0])
self.run("widget_set_value", target={"label": "Process"}, value=False)
self.run("widget_set_value", target={"option": "layer_height"}, value="0.16")
self.t.equal(f"{s} 5: the layer height", self.process("layer_height"), "0.16")
first = {"option": "initial_layer_print_height"}
reply = self.run("keyboard_press", target=first, keys="ctrl+a", text="0.24")
self.t.equal(f"{s} 6: the reply", reply, {"sent": "ctrl+a", "to": "TextInput", "typed": "0.24"})
self.run("keyboard_press", target=first, keys="Return")
self.t.equal(f"{s} 6: typing leaves a native text field as it was", self.process("initial_layer_print_height"),
"0.2")
job = self.c.call("action_run", id=PREFERENCES)
self.t.equal(f"{s} 7: the action waits on its dialog",
(job.get("status"), [d.get("title") for d in job.get("dialogs", [])]),
("blocked_by_dialog", ["Preferences"]))
self.c.call("dialog_answer", dialog={"title": "Preferences"}, button="close")
try:
self.c.await_job(job, timeout=60)
self.t.check(f"{s} 7: the action's job ends without an error", True)
except orca_mcp.McpError as e:
self.t.check(f"{s} 7: the action's job ends without an error", False, str(e))
self.t.equal(f"{s} 7: no dialog", self.c.call("app_state")["dialogs"], [])
reply = self.run("plate_slice")
self.t.equal(f"{s} 8: the slice's outcome", [p.get("outcome") for p in reply.get("plates", [])], ["ok"])
gcode = self.out("session.gcode")
self.run("project_export", path=gcode, overwrite=True)
with open(gcode, encoding="utf-8", errors="replace") as f:
lines = f.read().splitlines()
for line in ("; layer_height = 0.16", "; initial_layer_print_height = 0.2"):
self.t.check(f"{s} 8: the G-code's config holds {line!r}", line in lines, "")
heights = []
for line in lines:
if line.startswith("; Z_HEIGHT:"):
z = float(line.split(":", 1)[1])
if z not in heights:
heights.append(z)
if len(heights) == 2:
break
self.t.near(f"{s} 8: the first two layers' heights", heights, [0.2, 0.36], 1e-6)
report = self.run("recording_stop", silent=True)
self.t.equal(f"{s} 9: the report's end", report.get("ended"), "stopped")
self.same_path(f"{s} 9: the report's path", report.get("path"), session)
self.t.check(f"{s} 9: at least 5 frames captured and written",
report.get("frames", 0) >= 5 and report.get("written", 0) >= 5, report)
self.t.equal(f"{s} 9: no frame failed", report.get("failed"), 0)
self.t.check(f"{s} 9: it ran over a second", report.get("seconds", 0) > 1, report.get("seconds"))
self.t.check(f"{s} 9: a capture took time", report.get("capture_ms", 0) > 0, report.get("capture_ms"))
self.t.equal(f"{s} 9: the video's size", (report.get("width"), report.get("height")), main)
self.t.equal(f"{s} 9: the report's size is the file's", report.get("size_bytes"), os.path.getsize(session))
self.recording_is(f"{s} 9")
self.mkv_holds(f"{s} 9", session, main, 100, report.get("written", -1), report.get("seconds", 0))
mp4_path = self.out("session.mp4")
call = lambda: self.c.call("recording_encode", save_path=mp4_path, overwrite=True, keep_raw_video_file=True)
why = self.can_encode("libx265")
if why is None:
reply = self.c.await_job(call(), timeout=300)
self.same_path(f"{s} 10: the MP4's path", reply.get("path"), mp4_path)
self.same_path(f"{s} 10: the source", reply.get("source"), session)
self.t.equal(f"{s} 10: the encode", {k: reply.get(k) for k in ("codec", "encoder", "raw_video_file_deleted")},
{"codec": "h265", "encoder": "libx265", "raw_video_file_deleted": False})
self.t.equal(f"{s} 10: the reply's size is the file's", reply.get("size_bytes"), os.path.getsize(mp4_path))
info = mp4(mp4_path)
self.t.equal(f"{s} 10: the MP4 is H.265", info.get("entry"), "hvc1")
self.t.near(f"{s} 10: the MP4's duration", info.get("seconds"), report.get("seconds", 0), 0.3)
self.encoded["h265"] = "yes"
else:
self.encode_refused(f"{s} 10", "libx265", call)
self.t.check(f"{s} 10: no MP4", not os.path.exists(mp4_path), mp4_path)
for check in ("the MP4's path", "the source", "the encode", "the MP4 is H.265", "the MP4's duration"):
self.t.skip(f"{s} 10: {check}", why)
self.encoded["h265"] = f"no ({why})"
self.t.check(f"{s} 10: the .mkv is still there", os.path.exists(session), session)
def selected(self):
return (self.c.call("app_state").get("selection") or {}).get("objects", [])
def process(self, key):
return self.c.call("settings_get", type="process", keys=[key])["items"][0]["value"]
def nested(self):
s = "a recording a replay starts"
self.start(s)
canvas = fitted(*self.capture("canvas"))
inner = self.out("inner.mkv")
replay = {"orca_replay_version": "0.2.0", "name": "inner", "steps": [
{"tool": "recording_start", "args": {"target": "canvas", "fps": 5, "save_path": inner, "overwrite": True},
"expect": {"/target": {"eq": "canvas"}, "/fps": {"eq": 5}}},
{"tool": "view_set", "args": {"camera": "iso"}},
{"tool": "mouse_gesture", "args": {"action": "drag", "x": 400, "y": 300, "to": [500, 340]}}]}
reply = self.run("replay_run", replay=replay, out_dir=self.out("inner_replay"))
self.t.equal(f"{s} 1: the replay passed", reply.get("passed"), True)
self.t.check(f"{s} 1: no unfinished recording", "unfinished_recording" not in reply, reply)
self.recording_is(f"{s} 1: the recording ended with the replay")
report = self.run("recording_stop", silent=True)
self.t.equal(f"{s} 2: the report's end", report.get("ended"), "run_ended")
self.same_path(f"{s} 2: the report's path", report.get("path"), inner)
self.t.check(f"{s} 2: at least one frame written", report.get("written", 0) >= 1, report)
self.t.equal(f"{s} 2: no frame failed", report.get("failed"), 0)
self.t.equal(f"{s} 2: the video's size", (report.get("width"), report.get("height")), canvas)
self.mkv_holds(f"{s} 2", inner, canvas, 200, report.get("written", -1))
self.t.refused(f"{s} 3: an ended recording is reported once",
lambda: self.c.call("recording_stop", silent=True), words="No recording is running")
self.recording_is(f"{s} 3")
mp4_path = self.out("inner.mp4")
call = lambda: self.c.call("recording_encode", overwrite=True, codec="h264")
why = self.can_encode("libx264")
if why is None:
reply = self.c.await_job(call(), timeout=300)
self.same_path(f"{s} 4: the MP4's path", reply.get("path"), mp4_path)
self.same_path(f"{s} 4: the session's last finished recording is the source", reply.get("source"), inner)
self.t.equal(f"{s} 4: the encode", {k: reply.get(k) for k in ("encoder", "raw_video_file_deleted")},
{"encoder": "libx264", "raw_video_file_deleted": True})
self.t.check(f"{s} 4: the .mkv is gone", not os.path.exists(inner), inner)
self.t.equal(f"{s} 4: the MP4 is H.264", mp4(mp4_path).get("entry"), "avc1")
self.encoded["h264"] = "yes"
else:
self.encode_refused(f"{s} 4", "libx264", call)
self.t.check(f"{s} 4: no MP4", not os.path.exists(mp4_path), mp4_path)
self.t.check(f"{s} 4: the .mkv is still there", os.path.exists(inner), inner)
for check in ("the MP4's path", "the source", "the encode", "the .mkv is gone", "the MP4 is H.264"):
self.t.skip(f"{s} 4: {check}", why)
self.encoded["h264"] = f"no ({why})"
reply = self.run("recording_start", save_path=inner, overwrite=True)
self.t.equal(f"{s} 5: no overlays by default", (reply.get("captions"), reply.get("pointer")), (False, False))
self.recording_is(f"{s} 5: the replay's end released the file", inner)
reply = self.run("recording_stop", silent=True)
self.t.equal(f"{s} 6: the report's end", reply.get("ended"), "stopped")
self.recording_is(f"{s} 6")
def overlays(self):
s = "overlays and the time limit"
self.start(s)
plain = self.out("plain.mkv")
for step, args, overlays in ((1, {"pointer": True}, (False, True)), (3, {"captions": True}, (True, False))):
reply = self.run("recording_start", save_path=plain, overwrite=True, **args)
self.t.equal(f"{s} {step}: captions and pointer", (reply.get("captions"), reply.get("pointer")), overlays)
self.recording_is(f"{s} {step}", plain)
reply = self.run("recording_stop", silent=True)
self.t.equal(f"{s} {step + 1}: the report's end", reply.get("ended"), "stopped")
self.recording_is(f"{s} {step + 1}")
short = self.out("short.mkv")
reply = self.run("recording_start", save_path=short, overwrite=True, max_seconds=2)
self.t.equal(f"{s} 5: the limit", reply.get("max_seconds"), 2)
self.recording_is(f"{s} 5", short)
deadline = time.monotonic() + 10
while self.recording() is not None and time.monotonic() < deadline:
time.sleep(0.25)
self.recording_is(f"{s} 6: the recording ended on its own within 10 s")
report = self.run("recording_stop", silent=True)
self.t.equal(f"{s} 7: the limit ended it", report.get("ended"), "max_seconds")
self.t.near(f"{s} 7: it ran for the limit", report.get("seconds"), 2, 0.5)
self.t.near(f"{s} 7: the file's duration", mkv(short)["seconds"], report.get("seconds", 0), 0.1)
wrong = self.out("wrong.avi")
self.t.refused(f"{s} 8: a path that is not .mkv is refused",
lambda: self.c.call("recording_start", save_path=wrong), words="save_path must end with .mkv")
self.recording_is(f"{s} 8")
self.t.check(f"{s} 8: no file", not os.path.exists(wrong), wrong)
def encode_job(self, label, report, mp4_path, mkv_path, keep):
"""Steps 3 and 6 of the encode scenario: the encode the stop started, followed to its result."""
encode = report.get("encode") or {}
why = self.can_encode("libx264")
error, result = None, encode
if encode.get("job") and encode.get("status") in ("running", "blocked_by_dialog"):
try:
result = self.c.await_job(encode, timeout=300)
except orca_mcp.McpError as e:
error = str(e)
elif "error" in encode:
error = str(encode.get("error"))
if why is None:
self.t.check(f"{label}: the encode ends without an error", error is None, error)
self.same_path(f"{label}: the MP4's path", (result or {}).get("path"), mp4_path)
self.t.equal(f"{label}: the encode", {k: (result or {}).get(k) for k in ("encoder", "raw_video_file_deleted")},
{"encoder": "libx264", "raw_video_file_deleted": not keep})
self.t.check(f"{label}: the .mkv is {'kept' if keep else 'gone'}", os.path.exists(mkv_path) == keep, mkv_path)
info = mp4(mp4_path) if os.path.exists(mp4_path) else {}
self.t.equal(f"{label}: the MP4 is H.264", info.get("entry"), "avc1")
if not keep:
self.t.near(f"{label}: the MP4's duration", info.get("seconds"), report.get("seconds", 0), 0.3)
else:
self.t.check(f"{label}: the encode ends with the encoder's error",
error is not None and "has no libx264 encoder" in error, error)
self.t.check(f"{label}: the .mkv is still there", os.path.exists(mkv_path), mkv_path)
self.t.check(f"{label}: no MP4", not os.path.exists(mp4_path), mp4_path)
for check in ("the MP4's path", "the encode", "the MP4 is H.264"):
self.t.skip(f"{label}: {check}", why)
def encode_at_start(self):
s = "an encode asked for at the start"
self.start(s)
encoded, encoded_mp4 = self.out("encoded.mkv"), self.out("encoded.mp4")
args = dict(save_path=encoded, overwrite=True, encode=True, encode_preset="compatible")
if self.no_ffmpeg:
self.t.refused(f"{s} 1: the start is refused", lambda: self.c.call("recording_start", crf=30, **args),
words="Cannot encode: " + self.no_ffmpeg)
self.recording_is(f"{s} 1")
self.t.check(f"{s} 1: no file", not os.path.exists(encoded), encoded)
for step in range(2, 7):
self.t.skip(f"{s} {step}", self.no_ffmpeg)
return
reply = self.run("recording_start", crf=30, **args)
self.t.equal(f"{s} 1: the encode asked for", reply.get("encode"),
{"codec": "h264", "crf": 30, "speed": "medium", "profile": "high", "keep_raw_video_file": False})
self.recording_is(f"{s} 1", encoded)
report = self.c.call("recording_stop", silent=True)
self.same_path(f"{s} 2: the report's path", report.get("path"), encoded)
self.t.equal(f"{s} 2: the report's end", report.get("ended"), "stopped")
self.t.check(f"{s} 2: the report holds the encode", isinstance(report.get("encode"), dict), report)
self.recording_is(f"{s} 2")
self.encode_job(f"{s} 3", report, encoded_mp4, encoded, keep=False)
kept, kept_mp4 = self.out("kept.mkv"), self.out("kept.mp4")
reply = self.run("recording_start", **{**args, "save_path": kept, "keep_raw_video_file": True})
self.t.equal(f"{s} 4: the encode keeps the .mkv", (reply.get("encode") or {}).get("keep_raw_video_file"), True)
self.recording_is(f"{s} 4", kept)
report = self.c.call("recording_stop", silent=True)
self.t.check(f"{s} 5: the report holds the encode", isinstance(report.get("encode"), dict), report)
self.recording_is(f"{s} 5")
self.encode_job(f"{s} 6", report, kept_mp4, kept, keep=True)
def run_all(self):
self.run("window_set", size=[1600, 900])
for name, scenario in [("a recording while the GUI is driven", self.driven),
("a recording a replay starts", self.nested),
("overlays and the time limit", self.overlays),
("an encode asked for at the start", self.encode_at_start)]:
self.t.scenario(name, scenario)
if self.recording() is not None:
self.c.call("recording_stop", silent=True)
self.run("project_new", discard_changes=True, preset_changes="discard")
code = self.t.exit_code()
print("encodes checked: " + ", ".join(f"{codec} {self.encoded.get(codec, 'no (not reached)')}"
for codec in ("h265", "h264")), flush=True)
return code
def main():
ap = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
ap.add_argument("--out", help="folder for the recordings (default: a new temporary folder)")
args = ap.parse_args()
folder = args.out or tempfile.mkdtemp(prefix="orca-recording-")
os.makedirs(folder, exist_ok=True)
print(f"output folder: {folder}", flush=True)
client, _ = orca_mcp.session_client()
return RecordingTest(client, folder).run_all()
if __name__ == "__main__":
sys.exit(main())
+39 -2
View File
@@ -8,6 +8,12 @@ With Preferences open in a running job, 32 `app_wait` calls block on it (every b
more connections sit idle or half-sent, which fills the server's 64 connections. A `dialog_answer`
on a new connection must still close the dialog, and the waits must then return. Exits 0 when both
the idle and the half-sent variants pass.
The waits are seen holding every blocking slot before the holders open: app_wait and app_state are
observation calls that each take one of the server's 32 blocking slots, and with none free an
`app_state` replies `pending`. So does a wait that arrives while the test's own `app_state` holds
a slot; such a wait is sent again. An idle holder reads its ping's reply before the next one opens,
so the server has accepted it; the half-sent holders are given 1 s.
"""
import json
@@ -20,6 +26,10 @@ import time
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import orca_mcp # noqa: E402
# The reply an observation call gets when every blocking slot is taken.
PENDING = {"status": "pending", "note": "Too many calls are waiting right now; try again shortly."}
SLOTS_LIMIT_S = 10 # from the start of the 32 waits until app_state finds no slot free
def post(port, token, body, timeout=120):
"""One request on its own connection; returns the parsed JSON-RPC reply."""
@@ -57,6 +67,30 @@ def holder(port, token, half_sent):
return s
def wait_for_close(port, token, results):
"""One app_wait for the dialog to close. The test's own app_state, asked meanwhile, can hold the slot a wait
arrives for, so a wait replied `pending` is sent again, as the note asks, for up to SLOTS_LIMIT_S s."""
deadline = time.monotonic() + SLOTS_LIMIT_S
while True:
reply = call(port, token, "app_wait", {"for": "no_dialog", "timeout_s": 50})[0]
if {k: reply.get(k) for k in PENDING} != PENDING or time.monotonic() > deadline:
results.append(reply)
return
time.sleep(0.2)
def every_slot_taken(port, token):
"""Whether app_state, on a connection of its own every 0.2 s, replies that no blocking slot is free within
SLOTS_LIMIT_S s."""
deadline = time.monotonic() + SLOTS_LIMIT_S
while time.monotonic() < deadline:
state, _ = call(port, token, "app_state", {})
if {k: state.get(k) for k in PENDING} == PENDING:
return True
time.sleep(0.2)
return False
def run(port, token, half_sent):
job, _ = call(port, token, "action_run", {"id": "orca_command:open_preferences:orca"})
if job.get("status") != "blocked_by_dialog":
@@ -64,10 +98,11 @@ def run(port, token, half_sent):
waits, results = [], []
for _ in range(32):
t = threading.Thread(target=lambda: results.append(call(port, token, "app_wait", {"for": "no_dialog", "timeout_s": 50})[0]))
t = threading.Thread(target=wait_for_close, args=(port, token, results))
t.start()
waits.append(t)
time.sleep(2)
# A variant whose waits never take every slot still answers the dialog, so that its waits end before the next.
taken = every_slot_taken(port, token)
holders = [holder(port, token, half_sent) for _ in range(32)]
time.sleep(1)
@@ -83,6 +118,8 @@ def run(port, token, half_sent):
s.close()
satisfied = sum(1 for r in results if r.get("satisfied"))
print(f" dialog answered in {time.time() - started:.1f} s; {satisfied}/32 waits saw it close")
if not taken:
return f"app_state found a blocking slot free for {SLOTS_LIMIT_S} s after the 32 waits started"
return None if satisfied == 32 else f"only {satisfied} of 32 waits returned satisfied"
+28 -5
View File
@@ -7,8 +7,13 @@
Two refs outlive a change to what they were taken by. The Text gizmo's font button shows the font,
so its label changes with every pick: one ref is used for two picks. Texture Displacement names its
collapsed layer rows by place: a ref to "Layer 2" is clicked after the first layer is removed, when
that row is "Layer 1". The exported replay must find each item by what it is at each step, so replaying it
passes. Exits 0 when it does.
that row is "Layer 1". The click must open the layer the ref was taken for, which leaves the other
layer as the row "Layer 2". The exported replay must find each item by what it is at each step, so
replaying it passes. Exits 0 when every check passes.
A layer row is an item widget_list lists named exactly "Layer N" (its thumbnail is "Layer N image"), N its
place in the list counted from 1; the open layer has no row. object_list's painted.texture gives each
layer's slot.
"""
import os
@@ -29,6 +34,16 @@ def snapshot_ref(client, pattern):
return found.groups() if found else None
def layer_rows(client):
"""The names of the layer rows widget_list lists, "Layer N", leaving out the thumbnails ("Layer N image")."""
_, texts = client.call_with_text("widget_list")
return re.findall(r"name=(Layer \d+) (?!image)", "\n".join(texts))
def layer_slots(client):
return [layer["slot"] for layer in client.call("object_list")["plates"][0]["objects"][0]["parts"][0]["painted"]["texture"]]
def main():
client, _ = orca_mcp.session_client()
client.call("dialog_auto_answer", rules=[{"match": "Uniform scale", "button": "ok"},
@@ -57,7 +72,9 @@ def main():
checks.append(("the same ref picks the first font back", back.get("selected", "").startswith(shown), back))
# A ref to the second layer's row, clicked once the first layer is gone and the row is "Layer 1"
# (the third layer, the open one, has no row).
# (the third layer, the open one, has no row). Opening the gizmo makes the first layer, slot 0, which the
# import textures; each layer added takes the first free slot, so the two added are 1 and 2, slot 2 open.
# The layers are listed by slot, so the Remove of index 0 is slot 0's.
client.call("object_select", objects=[0])
client.call("widget_click", target={"gizmo": "Texture Displacement"})
client.call("gizmo_pick_file", action="texture_import", path=HEIGHTMAP)
@@ -67,9 +84,15 @@ def main():
checks.append(("the snapshot lists the second layer's row", row is not None, "no Layer 2 row"))
if row:
client.call("widget_click", target={"imgui_name": "Remove", "index": 0})
slots, rows = layer_slots(client), layer_rows(client)
checks.append(("the Remove leaves the second layer's row as Layer 1",
slots == [1, 2] and "Layer 1" in rows and "Layer 2" not in rows, (slots, rows)))
# The click opens slot 1, the layer the ref was taken for, and slot 2 becomes the row, "Layer 2". A ref
# that resolved to nothing, to the open layer or to a Remove button leaves other slots or rows.
clicked = client.call("widget_click", target=row[0])
layers = client.call("object_list")["plates"][0]["objects"][0]["parts"][0]["painted"]["texture"]
checks.append(("the old ref clicks the renamed row", len(layers) == 2, (clicked, len(layers))))
slots, rows = layer_slots(client), layer_rows(client)
checks.append(("the old ref clicks the renamed row",
slots == [1, 2] and "Layer 2" in rows and "Layer 1" not in rows, (clicked, slots, rows)))
# Its icon closes it: in a small window the object's info notification covers the panel's Close.
client.call("widget_click", target={"gizmo": "Texture Displacement"})
client.call("app_wait", **{"for": "idle"})
+15 -1
View File
@@ -13,7 +13,8 @@ added only when the run asks for it, and both flags are refused off Linux and to
the test's own folder; a test's environment has its own session file and temporary folder. Two test files
with one name are refused, a test whose run raises is recorded as an error, one that runs out of time is
ended so that what it started ends too, --history takes a bare file name, and -j or --jobs takes a whole
number from 1 up. Exits 0 when every check passes.
number from 1 up. Exits 0 when every check passes. The checks are asserts, so a Python that runs with its
asserts off (-O, or PYTHONOPTIMIZE, which the sweep's runner passes on) fails the test before any of them.
"""
import contextlib
@@ -36,6 +37,17 @@ def ok(name):
print(f"ok - {name}")
def asserts_live():
"""Whether Python runs the asserts every other check is, printing the check's line: with them off every check
would pass without checking anything."""
if sys.flags.optimize > 0:
print(f"FAIL - the asserts are live: Python runs with its asserts off (optimize level {sys.flags.optimize}, "
"from -O or PYTHONOPTIMIZE)")
return False
ok("the asserts are live")
return True
def refused(raw):
try:
entry(raw)
@@ -260,6 +272,8 @@ def check_shipped_manifest():
def main():
if not asserts_live():
return 1
check_entry()
check_manifest_problems()
check_order()
+6 -3
View File
@@ -57,15 +57,18 @@ def main():
check("prepare: camera_state has the zoom asked for", state.get("zoom") == 3, reply)
check("prepare: and look_at", state.get("look_at") == [50, 60, 0], reply)
check("prepare: camera_state looks straight down", state.get("elevation") == 90, reply)
# A capture of the 3D view itself, not a blank one marked approximate.
try:
client.call("window_screenshot", target="canvas", include_image=False)
check("prepare: the 3D view captures", True)
shot = client.call("window_screenshot", target="canvas", include_image=False)
check("prepare: the 3D view captures", shot.get("source") == "canvas" and shot.get("width", 0) > 0 and
shot.get("height", 0) > 0 and "approximate" not in shot, shot)
except orca_mcp.McpError as e:
check("prepare: the 3D view captures", False, str(e))
after = camera()
check("prepare: app_state.camera keeps the zoom after a frame", after.get("zoom") == 3, after)
check("prepare: and look_at", after.get("look_at") == [50, 60, 0], after)
check("prepare: camera_state has a projection type", after.get("type") in ("ortho", "perspective"), after)
# A fresh data folder's use_perspective_camera is on, and auto_perspective off.
check("prepare: camera_state has a projection type", after.get("type") == "perspective", after)
# 2. Clicks: click_px_per_mm is the zoom over the canvas's scale, 1 at 100 % and 1.5 at 150 % scaling.
px = after.get("click_px_per_mm")
+24 -6
View File
@@ -13,9 +13,10 @@ state normal and a size both bring it back to normal; on Wayland those checks ar
brings a minimized window back only by activating the app. A request that contradicts itself is
refused before anything changes. The Plugins window is sized and moved by its ref, which fails, pointing to
window_list, once the window has closed. Preferences, a modal dialog, is sized as "dialog" and moved by its
{label} locator, and never minimized; on X11 the main window, minimized, restored and raised while it is
open, stays under it in the X server's stacking order. A check that this window system or display can't run
here is reported SKIP, with why, and doesn't fail the test: it exits 0 when no check fails.
{label} locator, each read back from window_list, and never minimized; on X11 the main window, minimized,
restored and raised while it is open, stays under it in the X server's stacking order. A check that this window
system or display can't run here is reported SKIP, with why, and doesn't fail the test: it exits 0 when no check
fails.
"""
import ctypes
@@ -239,7 +240,9 @@ def main():
size = placed.get("size") or [0, 0]
check("Plugins: the reply has the size, or its minimum height with size adjusted",
size == [900, 700] or (size[0] == 900 and size[1] > 700 and "size" in placed.get("adjusted", [])), placed)
check("Plugins: the reply has the position", wayland or placed.get("position") == [100, 100], placed)
# The reply's fields are window_list's entry, which has no place on Wayland, where none is given or known.
check("Plugins: the reply has the position",
"position" not in placed if wayland else placed.get("position") == [100, 100], placed)
entry = find("Plugins") or {}
got = (entry.get("width"), entry.get("height")) if wayland else (entry.get("x"), entry.get("y"), entry.get("width"), entry.get("height"))
want = tuple(size) if wayland else tuple(placed.get("position", []) + size)
@@ -257,9 +260,16 @@ def main():
modal = wait_for(lambda: find("Preferences"), 15)
check("Preferences is open", modal, windows())
if modal:
dialog_size = [0, 0]
try:
dialog = client.call("window_set", target="dialog", size=[1000, 760])
check("dialog: window_set sizes the topmost modal dialog", True)
# As for Plugins, a minimum height above 760 holds the size to it, and the reply lists size as adjusted.
dialog_size = dialog.get("size") or [0, 0]
entry = find("Preferences") or {}
check("dialog: window_set sizes the topmost modal dialog",
(dialog_size == [1000, 760] or (dialog_size[0] == 1000 and dialog_size[1] > 760 and
"size" in dialog.get("adjusted", [])))
and [entry.get("width"), entry.get("height")] == dialog_size, f"{dialog} / {entry}")
check("dialog: the reply's kind is dialog", dialog.get("kind") == "dialog", dialog)
except orca_mcp.McpError as e:
check("dialog: window_set sizes the topmost modal dialog", False, str(e))
@@ -267,7 +277,15 @@ def main():
try:
moved = client.call("window_set", target={"label": "Preferences"},
**({"size": [1000, 760]} if wayland else {"position": [60, 60]}))
check("dialog: a {label} locator finds it", True)
entry = find("Preferences") or {}
if wayland:
check("dialog: a {label} locator finds it",
[entry.get("width"), entry.get("height")] == moved.get("size"), f"{moved} / {entry}")
else:
check("dialog: a {label} locator finds it",
moved.get("position") == [60, 60] and
[entry.get("x"), entry.get("y"), entry.get("width"), entry.get("height")] == [60, 60] + dialog_size,
f"{moved} / {entry}")
check("dialog: the reply's title is Preferences", moved.get("title") == "Preferences", moved)
except orca_mcp.McpError as e:
check("dialog: a {label} locator finds it", False, str(e))
+374
View File
@@ -0,0 +1,374 @@
#!/usr/bin/env python3
"""Where a setting applies, as the test_settings entry of tools/mcp/test-entries/filaments_settings.md designs it.
tools/mcp/orca_mcp.py launch
tools/mcp/test_settings.py
settings_list giving a type's settings whole, a saved preset's and a filament slot's, and the settings an object and a
region take; settings_set and settings_get on an object, a part, a modifier and a height range, named by index and taken
from the selection, with each value's effective value and source; what those settings do in the print; and the height
ranges replaced, the range that stays keeping its settings. After every step of the targets scenario the test reads
every target's settings back and compares them, whole, with the state the entry writes out. It runs on the harness's
default printer, the Bambu Lab X1 Carbon 0.4, and exits 0 when every check passes.
"""
import os
import sys
import tempfile
sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import orca_mcp # noqa: E402
from checks import Checks, run, wait # noqa: E402
PRINTER = "Bambu Lab X1 Carbon 0.4 nozzle"
PROCESS = "0.20mm Standard @BBL X1C"
B = "Bambu PLA Basic @BBL X1C"
G = "Bambu PETG Basic @BBL X1C"
PART_NOTE = 'A part\'s value (source "part", or in parts) applies only inside that part\'s volume.'
RANGE_NOTE = ('A height range\'s value (source "height_range", or in height_ranges) applies only between its min_z and '
'max_z.')
OVERLAP_NOTE = ('Inside a modifier, mesh or painted, that sets none of a key (source "overlapped_part"), the value of '
'the part it overlaps applies: that part\'s own in parts, else object_effective; which parts it overlaps '
'is not worked out.')
def g(value):
return "%g" % float(value)
def values_text(values):
"""{key: value} written as the entry writes it: `{extruder: 1, wall_loops: 4}`, keys in order, no quotes."""
return "{" + ", ".join(f"{k}: {values[k]}" for k in sorted(values)) + "}"
class SettingsTest:
def __init__(self, client, folder):
self.c = client
self.t = Checks()
self.folder = folder
# ---- Reads ----
def listed(self, kind, **args):
"""settings_list's reply: total, next_offset where given, and the items as {key, value, meta, targets}, meta
being whether the item has one."""
reply = self.c.call("settings_list", type=kind, **args)
items = [{"key": i["key"], "value": i.get("value"), "meta": "meta" in i, "targets": i.get("targets")}
for i in reply["items"]]
return {"total": reply["total"], "next_offset": reply.get("next_offset"), "items": items}
@staticmethod
def values(listing):
return {i["key"]: i["value"] for i in listing["items"]}
def item(self, target, key, **where):
"""One item of settings_get whole, the reply's note and the target the reply names."""
reply = self.c.call("settings_get", target=target, keys=[key], include_meta=False, **where)
item = reply["items"][0]
fields = {k: item[k] for k in ("value", "effective", "source", "parts", "height_ranges", "object_effective",
"object_source") if k in item}
return fields, reply.get("note"), self.named(reply)
@staticmethod
def named(reply):
out = {}
if "objects" in reply:
out["objects"] = [o.get("index") for o in reply["objects"]]
if "parts" in reply:
out["parts"] = [{"object": p.get("object"), "part": p.get("part")} for p in reply["parts"]]
if "height_range" in reply:
out["height_range"] = {k: reply["height_range"].get(k) for k in ("min_z", "max_z")}
return out
def overrides(self, target, **where):
"""What the target sets, as {key: value}; a filament of 0 (Default) does not count."""
reply = self.c.call("settings_get", target=target, include_meta=False, **where)
return {i["key"]: i["value"] for i in reply["items"] if not (i["key"] == "extruder" and i["value"] == "0")}
def cube(self):
return self.c.call("object_list", limit=500)["plates"][0]["objects"][0]
def ranges(self):
return [{"min_z": r["min_z"], "max_z": r["max_z"], "values": r["values"]}
for r in self.cube().get("layer_config_ranges", [])]
def targets(self):
"""`O · P0 · P1 · ranges`, a range as `min–max {values}`."""
ranges = ", ".join(f"{g(r['min_z'])}–{g(r['max_z'])} {values_text(r['values'])}" for r in self.ranges())
return " · ".join([values_text(self.overrides("object", object=0)),
values_text(self.overrides("part", object=0, part=0)),
values_text(self.overrides("part", object=0, part=1)), ranges])
def targets_are(self, label, want):
self.t.equal(f"{label}: the targets' settings", self.targets(), want)
def layers(self):
stats = self.c.call("plate_slice_stats", include=["layer_features"], limit=1000)
return [{"z": layer["z"], "height": layer["height"], "inner": layer["features"].get("Inner wall", 0),
"sparse": layer["features"].get("Sparse infill", 0)} for layer in stats["layers"]["items"]]
@staticmethod
def nearest(layers, z):
return min(layers, key=lambda layer: abs(layer["z"] - z))
# ---- Calls ----
def run(self, tool, **args):
return run(self.c, tool, **args)
def start(self, name):
self.run("project_new", discard_changes=True, preset_changes="discard")
self.run("view_set", tab="prepare")
wait(self.c, "idle")
for _ in range(32):
try:
self.c.call("filament_delete")
except orca_mcp.McpError:
break
self.run("preset_select", type="filament", name=B, filament_slot=1)
wait(self.c, "idle")
presets = self.c.call("app_state")["presets"]
self.t.equal(f"{name}: the start's presets", (presets["printer"], presets["process"], presets["filaments"]),
(PRINTER, PROCESS, [B]))
self.t.equal(f"{name}: the start has no object", self.c.call("object_list", limit=500)["total"], 0)
def whole(self, label, listing):
"""The list comes whole: as many items as total, no next page, no item with meta."""
self.t.equal(f"{label}: whole, without meta",
(len(listing["items"]), listing["next_offset"], [i["key"] for i in listing["items"] if i["meta"]]),
(listing["total"], None, []))
def has(self, label, listing, want):
values = self.values(listing)
self.t.equal(f"{label}: the values", {k: values.get(k) for k in want}, want)
# ---- Scenarios ----
def whole_types(self):
s = "a type's settings"
self.start(s)
process = self.listed("process")
self.t.check(f"{s} 1: at least 300 process settings", process["total"] >= 300, process["total"])
self.whole(f"{s} 1", process)
self.has(f"{s} 1", process, {"layer_height": "0.2", "wall_loops": "2", "sparse_infill_density": "15%",
"top_shell_layers": "5"})
keys = [i["key"] for i in process["items"]]
printer = self.listed("printer")
self.t.check(f"{s} 2: more than 100 printer settings", printer["total"] > 100, printer["total"])
self.whole(f"{s} 2", printer)
self.has(f"{s} 2", printer, {"nozzle_diameter": "0.4", "printable_height": "250"})
filament = self.listed("filament")
self.t.check(f"{s} 3: more than 100 filament settings", filament["total"] > 100, filament["total"])
self.whole(f"{s} 3", filament)
self.has(f"{s} 3", filament, {"filament_type": "PLA", "slow_down_layer_time": "4"})
pages, offset = [], None
for _ in range(20):
page = self.listed("process", include_meta=True, **({} if offset is None else {"offset": offset}))
pages.append(page)
offset = page["next_offset"]
if offset is None:
break
shapes = [(len(p["items"]), p["next_offset"]) for p in pages]
want = [(100, 100 * (n + 1)) for n in range(len(pages) - 1)]
self.t.equal(f"{s} 4: each page but the last holds 100 items and gives the next hundred", shapes[:-1], want)
self.t.check(f"{s} 4: the last page holds at most 100 items and no next_offset",
shapes[-1][0] <= 100 and shapes[-1][1] is None, shapes[-1])
self.t.equal(f"{s} 4: every item has meta", [i["key"] for p in pages for i in p["items"] if not i["meta"]], [])
self.t.check(f"{s} 4: the pages' keys are step 1's", [i["key"] for p in pages for i in p["items"]] == keys,
len([i for p in pages for i in p["items"]]))
page = self.listed("process", limit=50)
self.t.equal(f"{s} 5: 50 items, next_offset 50, none with meta",
(len(page["items"]), page["next_offset"], [i["key"] for i in page["items"] if i["meta"]]),
(50, 50, []))
self.t.check(f"{s} 5: step 1's first 50", [i["key"] for i in page["items"]] == keys[:50],
[i["key"] for i in page["items"]][:5])
fine = self.listed("process", preset="0.16mm High Quality @BBL X1C")
self.has(f"{s} 6", fine, {"layer_height": "0.16"})
self.t.equal(f"{s} 6: reading a preset does not select it", self.c.call("app_state")["presets"]["process"],
PROCESS)
self.run("filament_add")
self.run("preset_select", type="filament", name="Bambu PETG Basic", filament_slot=2)
wait(self.c, "idle")
self.t.equal(f"{s} 7: the slots' presets", self.c.call("app_state")["presets"]["filaments"], [B, G])
self.has(f"{s} 7: slot 2", self.listed("filament", filament_slot=2),
{"filament_type": "PETG", "slow_down_layer_time": "12"})
self.has(f"{s} 7: slot 1", self.listed("filament", filament_slot=1),
{"filament_type": "PLA", "slow_down_layer_time": "4"})
def object_and_region(self):
s = "what an object and a region take"
self.start(s)
process = self.values(self.listed("process"))
objects = self.listed("object")
regions = self.listed("region")
o, r = self.values(objects), self.values(regions)
self.t.check(f"{s} 1: more than 200 object settings and 100 region settings", len(o) > 200 and len(r) > 100,
(len(o), len(r)))
self.t.equal(f"{s} 1: every object setting is a process setting with its value",
[k for k in o if process.get(k, None) != o[k]], [])
self.t.equal(f"{s} 1: every region setting but layer_height is an object setting",
[k for k in r if k != "layer_height" and k not in o], [])
self.t.equal(f"{s} 1: both lists' walls and infill",
[(v.get("wall_loops"), v.get("sparse_infill_density")) for v in (o, r)],
[("2", "15%"), ("2", "15%")])
layer = [(i["value"], i["targets"]) for i in regions["items"] if i["key"] == "layer_height"]
self.t.equal(f"{s} 1: the region list's layer_height is a height range's", layer, [("0.2", ["height_range"])])
others = [("object", i["key"]) for i in objects["items"] if i["targets"] is not None] + [
("region", i["key"]) for i in regions["items"] if i["targets"] is not None and i["key"] != "layer_height"]
self.t.equal(f"{s} 1: no other item has targets", others, [])
def precedence(self):
s = "targets and precedence"
self.start(s)
plate = self.c.call("plate_list", limit=500)["items"][0]
x, y = (plate["origin"][i] + plate["size"][i] / 2 for i in (0, 1))
self.run("object_add_primitive", shape="cube", size=[20, 20, 20], name="cube", position=[x, y, 0])
self.run("part_add", object=0, type="modifier", shape="cube", size=[5, 5, 5], position=[x, y, 10])
self.run("object_set_height_ranges", object=0, ranges=[{"min_z": 0, "max_z": 5}, {"min_z": 5, "max_z": 10}])
wait(self.c, "idle")
cube = self.cube()
self.t.equal(f"{s}: the start's cube", ([p["type"] for p in cube["parts"]], cube["overrides"]),
(["part", "modifier"], ["extruder"]))
r0, r5 = "0–5 {extruder: 0, layer_height: 0.2}", "5–10 {extruder: 0, layer_height: 0.2}"
self.targets_are(f"{s}: the start", f"{{extruder: 1}} · {{}} · {{}} · {r0}, {r5}")
self.run("settings_set", type="filament", values={"slow_down_for_layer_cooling": False})
self.t.equal(f"{s}: the cooling slowdown is off",
self.c.call("settings_get", type="filament", keys=["slow_down_for_layer_cooling"],
include_meta=False)["items"][0]["value"], "0")
reply = self.run("plate_slice")
self.t.equal(f"{s}: the control slice", [p.get("outcome") for p in reply.get("plates", [])], ["ok"])
control = self.layers()
self.t.equal(f"{s}: the control's layers are 0.2 mm high",
[layer["z"] for layer in control if abs(layer["height"] - 0.2) > 0.001], [])
at3, at15 = self.nearest(control, 3.0), self.nearest(control, 15.0)
self.t.check(f"{s}: the control's layers at 3 and 15 mm print their inner walls alike",
abs(at3["z"] - 3.0) < 0.001 and abs(at15["z"] - 15.0) < 0.001 and
abs(at3["inner"] - at15["inner"]) <= 0.02 * at15["inner"], (at3, at15))
o4 = "{extruder: 1, wall_loops: 4}"
reply = self.run("settings_set", target="object", object=0, values={"wall_loops": 4})
self.t.equal(f"{s} 1: the reply", (reply.get("applied"), [o.get("index") for o in reply.get("objects", [])]),
({"wall_loops": "4"}, [0]))
self.targets_are(f"{s} 1", f"{o4} · {{}} · {{}} · {r0}, {r5}")
self.t.equal(f"{s} 1: object_list's overrides", self.cube()["overrides"], ["extruder", "wall_loops"])
reply = self.run("settings_set", target="part", object=0, part=1, values={"wall_loops": 5})
self.t.equal(f"{s} 2: the reply", (reply.get("applied"), self.named(reply).get("parts")),
({"wall_loops": "5"}, [{"object": 0, "part": 1}]))
self.targets_are(f"{s} 2", f"{o4} · {{}} · {{wall_loops: 5}} · {r0}, {r5}")
reply = self.run("settings_set", target="height_range", object=0, min_z=0, max_z=5, values={"wall_loops": 6})
named = self.named(reply)
self.t.equal(f"{s} 3: the reply", (reply.get("applied"), named.get("objects"), named.get("height_range")),
({"wall_loops": "6"}, [0], {"min_z": 0, "max_z": 5}))
r0 = "0–5 {extruder: 0, layer_height: 0.2, wall_loops: 6}"
self.targets_are(f"{s} 3", f"{o4} · {{}} · {{wall_loops: 5}} · {r0}, {r5}")
self.t.equal(f"{s} 3: the range's overrides", self.overrides("height_range", object=0, min_z=0, max_z=5),
{"layer_height": "0.2", "wall_loops": "6"})
reply = self.run("settings_set", target="height_range", object=0, min_z=5, max_z=10,
values={"layer_height": 0.12})
self.t.equal(f"{s} 4: the reply", reply.get("applied"), {"layer_height": "0.12"})
r5 = "5–10 {extruder: 0, layer_height: 0.12}"
after4 = f"{o4} · {{}} · {{wall_loops: 5}} · {r0}, {r5}"
self.targets_are(f"{s} 4", after4)
self.run("object_select", parts=[[0, 1]])
reply = self.c.call("settings_get", target="part")
self.t.equal(f"{s} 5: the selected part's settings",
(self.named(reply).get("parts"), {i["key"]: i["value"] for i in reply["items"]}),
([{"object": 0, "part": 1}], {"wall_loops": "5"}))
self.targets_are(f"{s} 5", after4)
fields, note, _ = self.item("part", "wall_loops")
self.t.equal(f"{s} 6: the selected part's walls", (fields, note),
({"value": "5", "effective": "5", "source": "part"}, PART_NOTE))
self.targets_are(f"{s} 6", after4)
reply = self.run("settings_set", target="part", object=0, part=0, values={"sparse_infill_density": "30%"})
self.t.equal(f"{s} 7: the reply", reply.get("applied"), {"sparse_infill_density": "30%"})
after7 = f"{o4} · {{sparse_infill_density: 30%}} · {{wall_loops: 5}} · {r0}, {r5}"
self.targets_are(f"{s} 7", after7)
fields, note, _ = self.item("part", "sparse_infill_density", object=0, part=1)
self.t.equal(f"{s} 8: the modifier's infill", (fields, note), (
{"value": None, "effective": None, "source": "overlapped_part", "object_effective": "15%",
"object_source": "global", "parts": [{"part": 0, "value": "30%"}]}, f"{PART_NOTE} {OVERLAP_NOTE}"))
self.targets_are(f"{s} 8", after7)
fields, note, _ = self.item("object", "wall_loops", object=0)
self.t.equal(f"{s} 9: the object's walls", (fields, note), (
{"value": "4", "effective": "4", "source": "object", "parts": [{"part": 1, "value": "5"}],
"height_ranges": [{"min_z": 0, "max_z": 5, "value": "6"}]}, f"{PART_NOTE} {RANGE_NOTE}"))
self.targets_are(f"{s} 9", after7)
reply = self.c.call("settings_get", target="height_range", object=0, min_z=0, max_z=5,
keys=["wall_loops", "sparse_infill_density"], include_meta=False)
items = {i["key"]: {k: v for k, v in i.items() if k != "key"} for i in reply["items"]}
self.t.equal(f"{s} 10: the range's walls and infill", (items, reply.get("note")), ({
"wall_loops": {"value": "6", "effective": "6", "source": "height_range", "parts": [{"part": 1, "value": "5"}]},
"sparse_infill_density": {"value": None, "effective": "15%", "source": "global",
"parts": [{"part": 0, "value": "30%"}]}}, f"{PART_NOTE} {RANGE_NOTE}"))
self.targets_are(f"{s} 10", after7)
self.run("object_select", objects=[0])
fields, note, named = self.item("height_range", "layer_height", min_z=5, max_z=10)
self.t.equal(f"{s} 11: the selected object stands for the range's object",
(named.get("objects"), named.get("height_range"), fields, note),
([0], {"min_z": 5, "max_z": 10}, {"value": "0.12", "effective": "0.12", "source": "height_range"},
RANGE_NOTE))
self.targets_are(f"{s} 11", after7)
reply = self.run("plate_slice")
self.t.equal(f"{s} 12: the slice", [p.get("outcome") for p in reply.get("plates", [])], ["ok"])
layers = self.layers()
for name, (bottom, top), height in [("the range's layers", (5.3, 9.7), 0.12),
("the layers above it", (10.5, 19.5), 0.2)]:
window = [(layer["z"], layer["height"]) for layer in layers if bottom <= layer["z"] <= top]
self.t.check(f"{s} 12: {name} are {g(height)} mm high",
bool(window) and all(abs(h - height) <= 0.001 for _, h in window), window)
low, high = self.nearest(layers, 3.0), self.nearest(layers, 15.0)
self.t.check(f"{s} 12: six walls in the range, four on the object, two in the control",
abs(low["z"] - 3.0) < 0.001 and low["inner"] > high["inner"] > at15["inner"], (low, high, at15))
self.t.check(f"{s} 12: part 0's infill at 30% prints longer than the control's 15%",
high["sparse"] > at15["sparse"], (high, at15))
self.targets_are(f"{s} 12", after7)
self.run("settings_set", type="filament", reset_all=True)
self.t.equal(f"{s} 12: the cooling slowdown is on again",
self.c.call("settings_get", type="filament", keys=["slow_down_for_layer_cooling"],
include_meta=False)["items"][0]["value"], "1")
self.run("object_set_height_ranges", object=0, ranges=[{"min_z": 0, "max_z": 5}, {"min_z": 5, "max_z": 12}])
after13 = f"{o4} · {{sparse_infill_density: 30%}} · {{wall_loops: 5}} · {r0}, 5–12 {{extruder: 0, layer_height: 0.2}}"
self.targets_are(f"{s} 13: the range that stays keeps its settings", after13)
path = os.path.join(self.folder, "settings.3mf")
self.run("project_save", path=path, overwrite=True)
self.run("project_new", discard_changes=True)
self.run("project_open", path=path)
wait(self.c, "idle")
self.targets_are(f"{s} 14: the project file keeps every target's settings", after13)
cube = self.cube()
self.t.equal(f"{s} 14: the cube", ([p["type"] for p in cube["parts"]], cube["overrides"]),
(["part", "modifier"], ["extruder", "wall_loops"]))
def run_all(self):
for name, scenario in [("a type's settings", self.whole_types),
("what an object and a region take", self.object_and_region),
("targets and precedence", self.precedence)]:
self.t.scenario(name, scenario)
self.run("project_new", discard_changes=True, preset_changes="discard")
return self.t.exit_code()
def main():
client, _ = orca_mcp.session_client()
with tempfile.TemporaryDirectory(prefix="orca-settings-") as folder:
return SettingsTest(client, folder).run_all()
if __name__ == "__main__":
sys.exit(main())
+6 -6
View File
@@ -5,9 +5,10 @@ So this test launches OrcaSlicer itself, twice, on a fresh data folder. The firs
(OrcaSlicer.conf, app.window_layout) as it starts its empty project (Plater::priv::reset()), and the app writes
OrcaSlicer.conf at its next idle moment; orca_mcp.py stop then ends it, on Windows by killing the process, which saves
nothing more. The test marks the sidebar's entry of that layout floating, as the drag leaves it, and the second run
starts with the sidebar floating. There view_set {sidebar_width} is refused and the width stays as it was. Floating is
off on Wayland, where the saved floating state is dropped; there the test says so and checks nothing. Each run is
stopped on every path out, and nothing but a run this test started is stopped.
starts with the sidebar floating. There view_set {sidebar_width} is refused and the width stays as it was. A native
Wayland app drops the saved floating state, so on Linux both runs start as X11 clients (GDK_BACKEND=x11, through
XWayland on a Wayland desktop), as the sweep's own launches do by default, and the checks run on every platform. Each
run is stopped on every path out, and nothing but a run this test started is stopped.
Run it as python tools/mcp/test_sidebar_floating.py [--bin PATH] [--datadir PATH].
"""
import contextlib
@@ -56,6 +57,8 @@ def launched(datadir, binary):
port = free_port()
session = os.path.join(datadir, "session.json")
env = app_env(dict(os.environ, ORCA_MCP_SESSION=session, ORCA_MCP_TOKEN=TOKEN), datadir)
if sys.platform.startswith("linux"):
env["GDK_BACKEND"] = "x11" # a native Wayland app drops the saved floating state
if os.path.exists(session):
os.remove(session)
try:
@@ -102,7 +105,6 @@ def main():
given = "--datadir" in extra
root = os.path.abspath(extra[extra.index("--datadir") + 1]) if given else tempfile.mkdtemp(prefix="osf-")
datadir = os.path.join(root, "floating")
wayland = sys.platform.startswith("linux") and os.environ.get("GDK_BACKEND") != "x11" and bool(os.environ.get("WAYLAND_DISPLAY"))
try:
with launched(datadir, binary) as orca:
started = orca is not None
@@ -112,8 +114,6 @@ def main():
with launched(datadir, binary) as orca:
if orca is None:
check("the app starts again", False)
elif wayland:
print("Floating is off on Wayland: the sidebar starts docked, nothing to check.")
else:
width = orca.call("app_state")["view"]["sidebar_width"]
try:
File diff suppressed because it is too large. Load diff
+94 -5
View File
@@ -8,13 +8,18 @@ no title bar on the dial.
Each page is reached from Home by a click on its tab, as a person switches pages: Prepare first, while the
plater still shows the 3D view it started with, then Design when the Design tab is on, and Preview. The page's
3D view must then hold the keyboard focus, as a focused sidebar control keeps Space for itself, and Space sent
to the focused window must open the dial. The view also takes the focus when the pointer enters it, so these
checks prove the switch itself only where no pointer rests on the view: on a native Wayland display, or on a
desktop with the pointer elsewhere. Where KWin answers on the display's D-Bus (the private one of a
to the focused window must open the dial. The view also takes the focus when the pointer enters it, so before
each tab click the test moves the system pointer to the primary display's top-left corner, (0, 0), and reads
it back there: the seeded main window opens at the work area's top left, so that corner is its top bar or lies
outside it, never in the 3D view below the tab bar. A pointer that does not read back at (0, 0) fails the
page's focus check. On a native Wayland display, where an app can neither move the pointer nor read where it
is, the focus checks are reported SKIP. Where KWin answers on the display's D-Bus (the private one of a
`--headless` launch, else the caller's), the frame KWin reports for the dial must be the dial's own size: a
title bar of KWin's makes the frame taller. Run it on a freshly launched app. Exits 0 when every check passes.
"""
import ctypes
import ctypes.util
import os
import re
import subprocess
@@ -25,6 +30,69 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import orca_mcp # noqa: E402
def park_pointer(display):
"""Moves the system pointer to (0, 0), the primary display's top-left corner, and returns where the system then
reads it, as (x, y), or a string saying why it could not be moved or read."""
if os.name == "nt":
from ctypes import wintypes
user32 = ctypes.windll.user32
if not user32.SetCursorPos(0, 0):
return f"SetCursorPos failed ({ctypes.GetLastError()})"
point = wintypes.POINT()
if not user32.GetCursorPos(ctypes.byref(point)):
return f"GetCursorPos failed ({ctypes.GetLastError()})"
return (point.x, point.y)
if sys.platform == "darwin":
class CGPoint(ctypes.Structure):
_fields_ = [("x", ctypes.c_double), ("y", ctypes.c_double)]
graphics = ctypes.CDLL(ctypes.util.find_library("CoreGraphics")
or "/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics")
foundation = ctypes.CDLL(ctypes.util.find_library("CoreFoundation"))
graphics.CGWarpMouseCursorPosition.argtypes = [CGPoint]
graphics.CGEventCreate.restype = ctypes.c_void_p
graphics.CGEventCreate.argtypes = [ctypes.c_void_p]
graphics.CGEventGetLocation.restype = CGPoint
graphics.CGEventGetLocation.argtypes = [ctypes.c_void_p]
foundation.CFRelease.argtypes = [ctypes.c_void_p]
if graphics.CGWarpMouseCursorPosition(CGPoint(0, 0)) != 0:
return "CGWarpMouseCursorPosition failed"
event = graphics.CGEventCreate(None)
if not event:
return "CGEventCreate failed"
location = graphics.CGEventGetLocation(event)
foundation.CFRelease(event)
return (round(location.x), round(location.y))
path = ctypes.util.find_library("X11")
if not path or not display:
return "libX11 or the X display is not found"
x = ctypes.CDLL(path)
x.XOpenDisplay.restype = ctypes.c_void_p
x.XOpenDisplay.argtypes = [ctypes.c_char_p]
x.XDefaultRootWindow.restype = ctypes.c_ulong
x.XDefaultRootWindow.argtypes = [ctypes.c_void_p]
x.XWarpPointer.argtypes = [ctypes.c_void_p, ctypes.c_ulong, ctypes.c_ulong, ctypes.c_int, ctypes.c_int,
ctypes.c_uint, ctypes.c_uint, ctypes.c_int, ctypes.c_int]
x.XSync.argtypes = [ctypes.c_void_p, ctypes.c_int]
ulong, cint, cuint = ctypes.POINTER(ctypes.c_ulong), ctypes.POINTER(ctypes.c_int), ctypes.POINTER(ctypes.c_uint)
x.XQueryPointer.argtypes = [ctypes.c_void_p, ctypes.c_ulong, ulong, ulong, cint, cint, cint, cint, cuint]
x.XCloseDisplay.argtypes = [ctypes.c_void_p]
dpy = x.XOpenDisplay(display.encode())
if not dpy:
return f"the X display {display} does not open"
try:
root = x.XDefaultRootWindow(dpy)
x.XWarpPointer(dpy, 0, root, 0, 0, 0, 0, 0, 0)
x.XSync(dpy, 0)
root_ret, child = ctypes.c_ulong(), ctypes.c_ulong()
rx, ry, wx, wy, mask = ctypes.c_int(), ctypes.c_int(), ctypes.c_int(), ctypes.c_int(), ctypes.c_uint()
if not x.XQueryPointer(dpy, root, ctypes.byref(root_ret), ctypes.byref(child), ctypes.byref(rx), ctypes.byref(ry),
ctypes.byref(wx), ctypes.byref(wy), ctypes.byref(mask)):
return "XQueryPointer found the pointer on another screen"
return (rx.value, ry.value)
finally:
x.XCloseDisplay(dpy)
def kwin_frames(session):
"""[(caption, width, height)] of the app's windows as KWin frames them, or None when no KWin answers."""
env = dict(os.environ)
@@ -58,10 +126,19 @@ def kwin_frames(session):
def main():
client, session = orca_mcp.session_client()
checks = []
skipped = []
wayland = client.call("app_state").get("display_backend") == "wayland"
display = session.get("display") or os.environ.get("DISPLAY")
parked = [] # where the pointer read back after each move before a tab click of the current switch
def check(name, ok, detail=""):
checks.append((name, bool(ok), detail))
def park():
"""Moves the pointer off the 3D view, to (0, 0), before a tab click, and keeps where it read back."""
if not wayland:
parked.append(park_pointer(display))
def wait_for(predicate, timeout):
deadline = time.time() + timeout
while time.time() < deadline:
@@ -80,8 +157,11 @@ def main():
tabs = tree()
home = re.search(r"\[(w\d+)\] tab \[", tabs)
page = re.search(rf'\[(w\d+)\] tab "{re.escape(label)}"', tabs)
parked.clear()
park()
client.call("widget_click", target=home.group(1))
wait_for(lambda: client.call("app_state")["tab"] == "home", 10)
park()
client.call("widget_click", target=page.group(1))
return wait_for(lambda: client.call("app_state")["tab"] == tab, 10)
@@ -99,7 +179,14 @@ def main():
for label, tab in pages:
check(f"{label}: the tab is shown", switch_to(label, tab))
focused = [line.strip() for line in tree().splitlines() if "[focused]" in line]
check(f"{label}: its 3D view holds the keyboard focus", focused and "name=OrcaSceneCanvas" in focused[0], focused)
if wayland:
skipped.append((f"{label}: its 3D view holds the keyboard focus",
"on a native Wayland display an app can neither move the pointer off the view nor read "
"where it is"))
else:
check(f"{label}: its 3D view holds the keyboard focus",
all(p == (0, 0) for p in parked) and focused and "name=OrcaSceneCanvas" in focused[0],
f"the pointer read back at {parked} after each move to (0, 0); focused: {focused}")
client.call("keyboard_press", keys="Space")
opened = wait_for(dial, 10)
check(f"{label}: Space opens the Speed Dial", opened)
@@ -124,7 +211,9 @@ def main():
failed = [c for c in checks if not c[1]]
for name, ok, detail in checks:
print(f"{'ok ' if ok else 'FAIL'} {name}" + ("" if ok or not detail else f"\n {detail}"))
print(f"{len(checks) - len(failed)} of {len(checks)} checks passed")
for name, why in skipped:
print(f"SKIP {name}: {why}")
print(f"{len(checks) - len(failed)} of {len(checks)} checks passed" + (f", {len(skipped)} skipped" if skipped else ""))
return 1 if failed else 0
+68 -32
View File
@@ -5,10 +5,12 @@
tools/mcp/test_stdio_bridge.py [--bin build/src/Release/orca-slicer]
The bridge finds the instance through the discovery file in the launch's datadir, so this also
checks that file. A second bridge, given an empty datadir and a port nothing serves, must answer the
handshake and list the same tools without starting OrcaSlicer. A third, on a fresh datadir, must
start OrcaSlicer for its first tool call, serving on the bridge's port; the test stops that app.
Exits 0 when every check passes.
checks that file. Every line a bridge writes is kept, in order: each request gets exactly one reply
line, a malformed line gets one error line with no id, and a notification gets none. A second
bridge sends the instance a 2026-07-28 request as its only line, with no handshake. A third, given
an empty datadir and a port nothing serves, must answer the handshake and list the same tools
without starting OrcaSlicer. A fourth, on a fresh datadir, must start OrcaSlicer for its first tool
call, serving on the bridge's port; the test stops that app. Exits 0 when every check passes.
"""
import argparse
@@ -76,16 +78,34 @@ def stop_process(pid):
def bridge(binary, datadir, lines, env, extra=()):
"""Feeds `lines` to one bridge process and returns its replies by id."""
"""Feeds `lines` to one bridge process and returns every line it wrote, in order, each parsed as one reply (a
line that is not JSON as {"line": its text})."""
proc = subprocess.run([binary, "--mcp-stdio", "--datadir", datadir, *extra], input="\n".join(lines) + "\n",
capture_output=True, text=True, timeout=120, env=env)
replies = {}
replies = []
for line in proc.stdout.splitlines():
msg = json.loads(line)
replies[msg.get("id")] = msg
try:
replies.append(json.loads(line))
except ValueError:
replies.append({"line": line})
return replies
def ids(replies):
return [r.get("id") for r in replies]
def reply(replies, id):
"""The first reply with this id, or {}."""
return next((r for r in replies if r.get("id") == id), {})
def app_state_of(msg):
"""The app_state a tools/call reply's text content holds, or {}."""
text = (msg.get("result", {}).get("content") or [{}])[0].get("text", "")
return json.loads(text) if text.startswith("{") else {}
def main():
parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument("--bin", help="orca-slicer binary (default: the one launch found)")
@@ -99,6 +119,12 @@ def main():
legacy = "2025-06-18"
modern = "2026-07-28"
def modern_app_state(id):
return json.dumps({"jsonrpc": "2.0", "id": id, "method": "tools/call",
"params": {"name": "app_state", "arguments": {},
"_meta": {"io.modelcontextprotocol/protocolVersion": modern}}})
replies = bridge(binary, session["datadir"], [
json.dumps({"jsonrpc": "2.0", "id": 1, "method": "initialize",
"params": {"protocolVersion": legacy, "capabilities": {}, "clientInfo": {"name": "test", "version": "1"}}}),
@@ -106,9 +132,7 @@ def main():
json.dumps({"jsonrpc": "2.0", "id": 2, "method": "tools/list"}),
json.dumps({"jsonrpc": "2.0", "id": 3, "method": "tools/call", "params": {"name": "app_state", "arguments": {}}}),
"{not json",
json.dumps({"jsonrpc": "2.0", "id": 4, "method": "tools/call",
"params": {"name": "app_state", "arguments": {},
"_meta": {"io.modelcontextprotocol/protocolVersion": modern}}}),
modern_app_state(4),
json.dumps({"jsonrpc": "2.0", "id": 5, "method": "tools/call", "params": {"name": "no_such_tool", "arguments": {}}}),
], env)
@@ -119,17 +143,29 @@ def main():
if not ok:
failures.append(name)
init = replies.get(1, {}).get("result", {})
check("initialize negotiates the client's version", init.get("protocolVersion") == legacy, replies.get(1))
check("the notification gets no reply", set(replies) <= {1, 2, 3, 4, 5, None}, sorted(map(str, replies)))
names = [t["name"] for t in replies.get(2, {}).get("result", {}).get("tools", [])]
init = reply(replies, 1).get("result", {})
check("initialize negotiates the client's version", init.get("protocolVersion") == legacy, reply(replies, 1))
# One line per request and one for the malformed line, in order: a reply to the notification would be a
# seventh line, or a second with no id.
check("the notification gets no reply", ids(replies) == [1, 2, 3, None, 4, 5], ids(replies))
tools = reply(replies, 2).get("result", {}).get("tools", [])
names = [t["name"] for t in tools]
check("tools/list lists app_state and widget_list", "app_state" in names and "widget_list" in names, names[:5])
state = json.loads(replies.get(3, {}).get("result", {}).get("content", [{}])[0].get("text", "{}"))
state = app_state_of(reply(replies, 3))
check("app_state answers through the bridge", state.get("ready") is True, state)
check("malformed input is a parse error", replies.get(None, {}).get("error", {}).get("code") == -32700, replies.get(None))
modern_result = replies.get(4, {}).get("result", {})
check("a 2026-07-28 request is served without a handshake", modern_result.get("resultType") == "complete", replies.get(4))
check("an unknown tool is a JSON-RPC error", replies.get(5, {}).get("error", {}).get("code") == -32602, replies.get(5))
check("malformed input is a parse error", reply(replies, None).get("error", {}).get("code") == -32700,
reply(replies, None))
check("a 2026-07-28 request after a 2025-06-18 handshake is served",
reply(replies, 4).get("result", {}).get("resultType") == "complete", reply(replies, 4))
check("an unknown tool is a JSON-RPC error", reply(replies, 5).get("error", {}).get("code") == -32602,
reply(replies, 5))
# A 2026-07-28 request needs no handshake: a bridge of its own gets it as its only line.
alone = bridge(binary, session["datadir"], [modern_app_state(1)], env)
first = alone[0] if alone else {}
check("a 2026-07-28 request is served without a handshake",
ids(alone) == [1] and first.get("result", {}).get("resultType") == "complete" and
app_state_of(first).get("ready") is True, alone)
# With no instance answering, everything but a tool call is answered from the bridge's own catalog.
empty = tempfile.mkdtemp(prefix="orca-bridge-offline-")
@@ -145,16 +181,17 @@ def main():
json.dumps({"jsonrpc": "2.0", "id": 6, "method": "ping"}),
], env, ["--mcp-port", str(free_port())])
check("offline: initialize negotiates the client's version",
offline.get(1, {}).get("result", {}).get("protocolVersion") == legacy, offline.get(1))
check("offline: the notification gets no reply", set(offline) <= {1, 2, 3, 4, 6, None}, sorted(map(str, offline)))
check("offline: tools/list matches the running app's",
offline.get(2, {}).get("result", {}).get("tools") == replies.get(2, {}).get("result", {}).get("tools"),
len(offline.get(2, {}).get("result", {}).get("tools", [])))
check("offline: ping answers", offline.get(3, {}).get("result") == {}, offline.get(3))
check("offline: an unknown method is the server's error", offline.get(4, {}).get("error", {}).get("code") == -32601, offline.get(4))
reply(offline, 1).get("result", {}).get("protocolVersion") == legacy, reply(offline, 1))
check("offline: the notification gets no reply", ids(offline) == [1, 2, 3, 4, None, 6], ids(offline))
offline_tools = reply(offline, 2).get("result", {}).get("tools")
check("offline: tools/list matches the running app's", offline_tools == tools, len(offline_tools or []))
check("offline: ping answers", reply(offline, 3).get("result") == {}, reply(offline, 3))
check("offline: an unknown method is the server's error",
reply(offline, 4).get("error", {}).get("code") == -32601, reply(offline, 4))
check("offline: a jsonrpc that is not a string is an invalid request",
offline.get(None, {}).get("error", {}).get("code") == -32600, offline.get(None))
check("offline: the bridge answers after a malformed message", offline.get(6, {}).get("result") == {}, offline.get(6))
reply(offline, None).get("error", {}).get("code") == -32600, reply(offline, None))
check("offline: the bridge answers after a malformed message", reply(offline, 6).get("result") == {},
reply(offline, 6))
check("offline: OrcaSlicer was not started", os.listdir(empty) == [], os.listdir(empty))
finally:
shutil.rmtree(empty, ignore_errors=True)
@@ -173,11 +210,10 @@ def main():
"params": {"protocolVersion": legacy, "capabilities": {}, "clientInfo": {"name": "test", "version": "1"}}}),
json.dumps({"jsonrpc": "2.0", "id": 2, "method": "tools/call", "params": {"name": "app_state", "arguments": {}}}),
], launch_env, ["--mcp-port", str(port)])
text = launched.get(2, {}).get("result", {}).get("content", [{}])[0].get("text", "")
state = json.loads(text) if text.startswith("{") else {}
state = app_state_of(reply(launched, 2))
# Not ready: a dialog the fresh datadir opens at startup may still be up.
check("launch: a tool call is answered by the OrcaSlicer it started, on the bridge's port",
state.get("mcp", {}).get("port") == port, launched.get(2))
state.get("mcp", {}).get("port") == port, reply(launched, 2))
discovery = read_discovery(fresh)
check("launch: the fresh datadir's discovery file names the bridge's port", discovery.get("port") == port, discovery)
finally:
+15 -7
View File
@@ -350,7 +350,10 @@ def main():
r = call("widget_click", target={"web": "Token link"})
check("a navigated url shows a credential parameter's value as REDACTED", r.get("navigated") is True and
r.get("url", "").endswith("#orca-token=REDACTED&view=2"), r)
check("and the snapshot shows no secret either", "fixture-secret" not in tree(target="dialog"), lambda: tree(target="dialog", query="webview"))
# The snapshot answers, and lists the link just clicked, so it is of the page whose URL holds the secret.
snapshot = tree(target="dialog")
check("and the snapshot shows no secret either", 'link "Token link"' in snapshot and "fixture-secret" not in snapshot,
lambda: snapshot or "widget_list gave no snapshot")
name = ref_of(tree(target="dialog"), 'text "Name"')
r = call("webview_run_javascript", code="el.value", target=name)
@@ -609,10 +612,11 @@ def main():
check("its page, whose CSP forbids eval, takes a click", r.get("clicked") == "Ping", r)
ping = ref_of(tree(query="Ping"), 'button "Ping"')
check("and saw it", wait_for(lambda: 'label "ping"' in tree(query="ping"), 3), lambda: tree(query="ping"))
# Whether the port's script channel is held to the page's CSP varies (WebView2's is not).
# WebView2 does not hold the injected script to the page's policy; WKWebView and WebKitGTK do, and the
# script runs through eval, which the policy forbids.
r = call("webview_run_javascript", code="1", target=ping)
check("webview_run_javascript there runs, or names the page's Content-Security-Policy",
r.get("result") == 1 or "Content-Security-Policy" in r.get("error", ""), r)
r.get("result") == 1 if os.name == "nt" else "Content-Security-Policy" in r.get("error", ""), r)
# A press left on the window's pad ends when a click lands on another page.
window_log = {"web": "Card one", "within": "MCP web fixture window"}
ups = page_log(window_log).count("pad up")
@@ -687,20 +691,24 @@ def main():
call("dialog_auto_answer", rules=[])
# A page that does not answer may hold another match, so a locator is refused until it does.
def pings():
"""The panel's ping log, which holds a ping by now: asked again while the panel's page has not answered,
as a listing with a query leaves such a page out."""
"""The panel's ping log as its label, without the ref the snapshot renumbers: asked again while the panel's
page has not answered, as a listing with a query leaves such a page out. A log not found reads as ""."""
end = time.time() + 15
while True:
line = next((line for line in tree(query="ping").splitlines() if 'label "ping' in line), "")
if line or time.time() >= end:
return line.split("]", 1)[-1].split("@", 1)[0].strip() # the label, without the ref the snapshot renumbers
return line.split("]", 1)[-1].split("@", 1)[0].strip()
time.sleep(0.2)
# Two clicks on Ping so far: "its page, whose CSP forbids eval, takes a click" and the one that ends the
# press held on the window's pad.
two_pings = 'label "ping ping"'
pinged = pings()
# The panel's page has the call's 5 s to answer, and the window's stalls past them.
stall("find", target=window_log)
r = call("widget_click", target={"web": "Ping"}, timeout_s=5)
check("a locator is refused while another candidate page does not answer", "may not be the only match" in r.get("error", ""), r)
check("and the panel's own page never saw that click", pings() == pinged, [pinged, pings()])
after = pings()
check("and the panel's own page never saw that click", pinged == two_pings and after == two_pings, [pinged, after])
# So is one while another candidate page fails the search: it breaks what the agent reads until that
# search has been answered.
when_asked("find", target=window_log, after="window.getComputedStyle = styles;",
+13 -5
View File
@@ -5,7 +5,8 @@
tools/mcp/test_webview_modal.py
Scripts run in the web view of the topmost modal dialog, whichever dialog it is (the preset bundle
dialog, by default and by locator, the export bundle dialog above it, the Flushing volumes dialog);
dialog, by default and by locator, the export bundle dialog above it, the Flushing volumes dialog, each
known by its page's URL or title);
the Home tab's web view behind a modal is refused, so is the bundle dialog's own web view once the
export bundle dialog is above it. A page that closes its dialog replies closed at once, not after the
timeout. Without a modal, the Home tab's web view still takes scripts. Exits 0 when every check passes.
@@ -98,12 +99,19 @@ def main():
client.call("view_set", tab="prepare")
client.call("widget_click", target={"label": "Add one filament"})
flush = client.call("widget_click", target={"label": "Flushing volumes"})
check("the Flushing volumes dialog opens", wait_dialogs(1), dialogs())
check("the Flushing volumes dialog opens",
wait_dialogs(1) and dialogs() == ["Flushing volumes for filament change"], dialogs())
# Its web view, too, shows about:blank until its first navigation starts.
for _ in range(50):
if "WipingDialog.html" in client.call_with_text("widget_list", target="dialog", query="webview")[1][0]:
break
time.sleep(0.1)
try:
title = client.call("webview_run_javascript", code="typeof document.title")["result"]
reply = client.call("webview_run_javascript", code="typeof document.title")
except orca_mcp.McpError as e:
title = str(e)
check("its page takes a script", title == "string", title)
reply = {"error": str(e)}
check("its page takes a script",
reply.get("result") == "string" and "web/flush/WipingDialog.html" in reply.get("url", ""), reply)
client.call("dialog_answer", button="close")
client.await_job(flush)
check("no dialog is left at the end", wait_dialogs(0), dialogs())
-66
View File
@@ -1,66 +0,0 @@
// A call with exactly an action's arguments does what a person's pick of the action does, and an action whose menu item
// and tool do the same thing runs the tool's function: calibration_generate_test with test alone asks in the test's
// dialog, and with silent runs with its defaults; View: Top turns the Design tab's camera; Go to tab and Go to layer
// take their value through action_run; plate_slice {preview: true} and Slice and Preview slice and show the Preview
// tab; Deselect All clears the selection of the view shown. Run on a live app with the Design tab
// (orca_mcp.py launch --cad):
// python3 tools/mcp/orca_mcp.py run-replay tools/mcp/tests/actions_ask.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "actions that ask",
"vars": {"cube": "${replay_dir}/../../../resources/handy_models/OrcaCube_v2.drc"},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "dialog_auto_answer", "args": {"rules": [{"match": "restore", "button": "no"}]}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
// ---- calibration_generate_test: test alone asks in the test's dialog; silent runs with its defaults ----
{"tool": "calibration_generate_test", "args": {"test": "temperature"}, "await": false, "save_as": "asked",
"expect": {"/status": {"eq": "blocked_by_dialog"}}},
{"tool": "app_wait", "args": {"for": "dialog"}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "Temperature calibration"}, "button": "cancel"}},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.asked}"}},
{"tool": "calibration_generate_test", "args": {"test": "temperature", "silent": true, "discard_changes": true, "preset_changes": "discard"},
"expect": {"/test": {"eq": "temperature"}}},
{"tool": "object_list", "expect": {"/total": {"ge": 1}, "/plates/0/objects/0/name": {"exists": true}}},
// ---- View: Top on the Design tab is view_set's own function, which turns the Design view's camera ----
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "project_import", "args": {"paths": ["${vars.cube}"]}, "expect": {"/added": {"eq": 1}}},
{"tool": "object_transform", "args": {"object": 0, "size": [20, 20, 20]}},
{"tool": "view_set", "args": {"tab": "design", "camera": "front"},
"expect": {"/camera_state/elevation": {"ge": -5, "le": 5}}},
{"tool": "action_run", "args": {"id": "view_top"},
"expect": {"/ran": {"eq": "orca_command:view_top:orca"}, "/camera_state/elevation": {"ge": 85}}},
{"tool": "app_state", "expect": {"/tab": {"eq": "design"}, "/camera/elevation": {"ge": 85}}},
// ---- Deselect All is object_select's own function: the selection of the view shown clears ----
{"tool": "view_set", "args": {"tab": "prepare"}, "expect": {"/tab": {"eq": "prepare"}}},
{"tool": "object_select", "args": {"objects": [0]}, "expect": {"/objects": {"eq": [0]}}},
{"tool": "action_run", "args": {"id": "deselect_all"},
"expect": {"/ran": {"eq": "orca_command:deselect_all:orca"}, "/empty": {"eq": true}, "/canvas": {"eq": "3d"}}},
{"tool": "app_state", "expect": {"/selection/empty": {"eq": true}}},
// ---- Go to tab and Go to layer take their value through action_run ----
{"tool": "action_run", "args": {"id": "go_to_tab", "args": {"tab": "preview"}}, "expect": {"/tab": {"eq": "preview"}}},
{"tool": "app_state", "expect": {"/tab": {"eq": "preview"}}},
{"tool": "plate_slice", "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
{"tool": "action_run", "args": {"id": "go_to_layer", "args": {"percent": 50}}},
// A 20 mm cube at the X1 Carbon's 0.2 mm layers has about a hundred; half of the range is near its middle.
{"tool": "plate_slice_stats", "args": {"include": ["view"]},
"expect": {"/view/layer_count": {"ge": 90, "le": 110}, "/view/layers/1": {"ge": 45, "le": 56}}},
// ---- plate_slice {preview: true} and Slice and Preview wait for the slice and show the Preview tab ----
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "object_transform", "args": {"object": 0, "translate": [5, 0, 0]}},
{"tool": "plate_slice", "args": {"preview": true}, "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
{"tool": "app_state", "expect": {"/tab": {"eq": "preview"}}},
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "object_transform", "args": {"object": 0, "translate": [-5, 0, 0]}},
{"tool": "action_run", "args": {"id": "slice_and_preview"},
"expect": {"/ran": {"eq": "orca_command:slice_and_preview:orca"}, "/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
{"tool": "app_state", "expect": {"/tab": {"eq": "preview"}}},
{"tool": "project_new", "args": {"discard_changes": true}}
]
}
-55
View File
@@ -1,55 +0,0 @@
// Arguments as agents often write them: names a command does not take but that stand for one it does
// (object for objects, action for id, key for keys, plate for plates), values in another JSON form (a
// lone path for a list, an index as a string), an action by the name inside its id, a camera
// direction as view_set's canvas, object_transform's position, app_wait with no condition, a gizmo by its
// toolbar title, legend rows as agents name them, project_export without a format, and settings_list's whole
// listing without meta. Run on a live app:
// python3 tools/mcp/orca_mcp.py run-replay tools/mcp/tests/agent_forms.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "agent argument forms",
"vars": {"cube": "${replay_dir}/../../../resources/handy_models/OrcaCube_v2.drc"},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "view_set", "args": {"tab": "prepare"}},
// ---- A lone path for paths; object and a string index for objects; an action's name for its id ----
{"tool": "project_import", "args": {"paths": "${vars.cube}"}, "expect": {"/added": {"eq": 1}}},
{"tool": "project_import", "args": {"paths": ["${vars.cube}"]}, "expect": {"/added": {"eq": 1}}},
{"tool": "object_select", "args": {"object": "1"}},
{"tool": "object_rename", "args": {"name": "renamed"}, "expect": {"/ran": {"eq": "object_rename"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/1/name": {"eq": "renamed"}, "/plates/0/objects/0/name": {"ne": "renamed"}}},
{"tool": "action_run", "args": {"action": "view_top"}, "expect": {"/ran": {"eq": "orca_command:view_top:orca"}}},
// ---- A camera direction as canvas; position for an absolute move; key for keys; app_wait for idle ----
{"tool": "view_set", "args": {"canvas": "front"}, "expect": {"/camera": {"eq": "front"}}},
{"tool": "object_transform", "args": {"object": 0, "position": [100, 110, 0]}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/instances/0/offset/0": {"ge": 99.99, "le": 100.01},
"/plates/0/objects/0/instances/0/offset/1": {"ge": 109.99, "le": 110.01}}},
{"tool": "keyboard_press", "args": {"key": "Escape"}},
{"tool": "app_wait", "args": {}, "expect": {"/satisfied": {"eq": true}}},
// ---- A gizmo by its toolbar title, in any case; replies name it as app_state does ----
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Support Painting"}}, "expect": {"/gizmo": {"eq": "FdmSupports"}, "/active": {"eq": true}}},
{"tool": "app_state", "expect": {"/gizmo/name": {"eq": "FdmSupports"}}},
{"tool": "widget_click", "args": {"target": {"gizmo": "support painting"}}, "expect": {"/active": {"eq": false}}},
// ---- plate for plates, as a string; project_export's format from the path ----
{"tool": "object_arrange", "args": {"plate": "0"}},
{"tool": "plate_slice", "args": {"plate": "0"}, "expect": {"/plates/0/outcome": {"eq": "ok"}}},
// ---- Legend rows in any case and with _ for a space; hiding rows this print lacks does nothing ----
{"tool": "view_set", "args": {"tab": "preview", "legend": {"sparse_infill": false, "Travel": false, "Prime tower": false, "Pauses": false}},
"expect": {"/legend/Sparse infill": {"eq": false}, "/legend/travel": {"eq": false}, "/legend/Prime tower": {"exists": false}}},
{"tool": "view_set", "args": {"legend": {"Sparse infill": true, "travel": true}}, "expect": {"/legend/Sparse infill": {"eq": true}}},
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "project_export", "args": {"path": "${out_dir}/forms.gcode", "overwrite": true}, "expect": {"/export": {"eq": "ok"}}},
{"tool": "project_export", "args": {"path": "${out_dir}/forms.stl", "overwrite": true}},
// ---- settings_list: a whole preset listing carries values only; settings_get: named keys with their meta ----
{"tool": "settings_list", "args": {"type": "process", "limit": 5}, "expect": {"/items/0/value": {"exists": true}, "/items/0/meta": {"exists": false}}},
{"tool": "settings_get", "args": {"type": "process", "keys": ["wall_loops"]}, "expect": {"/items/0/meta/type": {"exists": true}}}
]
}
-136
View File
@@ -1,136 +0,0 @@
// Makes every calibration test with calibration_generate_test, as the Calibration menu's dialogs do after OK, and
// checks the objects it added, the parameters it used and the presets it changed, slicing several of
// them (not input shaping, which the X1C's Marlin flavour cannot slice). It checks that temperatures
// are rounded down to 5 °C, that the refusals leave the project as it was (modified presets without
// changes, an argument the test does not take, a value the dialog refuses, the filament tab on another
// slot's modified preset with "keep"), that "discard" points the filament tab at slot 1, that "keep"
// keeps an edit, and that project_new drops the test's settings. It starts from the harness's default
// printer (Bambu Lab X1 Carbon) and reruns on the same datadir. Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/calibration.json --out /tmp/calibration
{
"orca_replay_version": "0.2.0",
"name": "calibration tests",
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "dialog_auto_answer", "args": {"rules": [{"match": "restore", "button": "no"}]}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "window_set", "args": {"size": [1600, 900]}},
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "app_state", "expect": {"/presets/filaments/1": {"exists": false}}},
// ---- Temperature: rounded down to the tower's 5 °C blocks, written to slot 1's filament ----
{"tool": "calibration_generate_test", "args": {"test": "temperature", "start": 252, "end": 232},
"expect": {"/test": {"eq": "temperature"}, "/params": {"eq": {"start": 250, "end": 230, "auto_scale": true}},
"/warnings/0": {"contains": "rounded down to 250"}, "/warnings/1": {"contains": "rounded down to 230"},
"/objects": {"eq": 1}, "/names": {"eq": ["temperature_tower.drc"]},
"/presets_changed/filament/filament_slot": {"eq": 1},
"/presets_changed/filament/changes/nozzle_temperature": {"exists": true},
"/result_keys": {"eq": {"type": "filament", "keys": ["nozzle_temperature", "nozzle_temperature_initial_layer"]}},
"/modified/filament/keys": {"contains": "nozzle_temperature"}}},
{"tool": "plate_slice", "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
// ---- Refused, changing nothing: modified presets without changes, an argument the test does not
// take, a value its dialog refuses ----
{"tool": "calibration_generate_test", "args": {"test": "max_volumetric", "discard_changes": true}, "optional": true},
{"tool": "calibration_generate_test", "args": {"test": "temperature", "step": 5, "discard_changes": true, "preset_changes": "discard"}, "optional": true},
{"tool": "calibration_generate_test", "args": {"test": "pressure_advance", "start": 0.01, "end": 0.05, "step": 0.051,
"discard_changes": true, "preset_changes": "discard"}, "optional": true},
{"tool": "object_list", "expect": {"/total": {"eq": 1}, "/plates/0/objects/0/name": {"eq": "temperature_tower.drc"}}},
{"tool": "preset_list", "args": {"type": "filament"},
"expect": {"/items/0/name": {"eq": "Bambu PLA Basic @BBL X1C"}, "/items/0/modified": {"eq": true}}},
// ---- Max volumetric speed: the temperature test's settings discarded first ----
{"tool": "calibration_generate_test", "args": {"test": "max_volumetric", "end": 15, "discard_changes": true, "preset_changes": "discard"},
"expect": {"/params": {"eq": {"start": 5, "end": 15, "step": 0.5}}, "/names": {"eq": ["SpeedTestStructure.drc"]},
"/discarded/filament/keys": {"contains": "nozzle_temperature"},
"/presets_changed/process/changes/spiral_mode": {"eq": "1"},
"/presets_changed/filament/changes/filament_max_volumetric_speed": {"exists": true}}},
{"tool": "plate_slice", "expect": {"/plates/0/outcome": {"eq": "ok"}}},
// ---- Pressure advance: tower, line and a 2 x 2 pattern batch; the pattern's defaults read back ----
{"tool": "calibration_generate_test", "args": {"test": "pressure_advance", "end": 0.06, "discard_changes": true, "preset_changes": "discard"},
"expect": {"/params": {"eq": {"method": "tower", "start": 0, "end": 0.06, "step": 0.002}}, "/names": {"eq": ["tower_with_seam.drc"]}}},
{"tool": "plate_slice", "expect": {"/plates/0/outcome": {"eq": "ok"}}},
{"tool": "calibration_generate_test", "args": {"test": "pressure_advance", "method": "line", "print_numbers": false, "discard_changes": true, "preset_changes": "discard"},
"expect": {"/params/print_numbers": {"eq": false}, "/params/end": {"eq": 0.1}, "/names": {"eq": ["pressure_advance_test.drc"]}}},
{"tool": "calibration_generate_test", "args": {"test": "pressure_advance", "method": "pattern", "accelerations": [1000, 2000], "speeds": [50, 100],
"discard_changes": true, "preset_changes": "discard"},
"expect": {"/objects": {"eq": 4},
"/names": {"eq": ["pa_pattern_50_1000", "pa_pattern_100_1000", "pa_pattern_50_2000", "pa_pattern_100_2000"]},
"/params/accelerations": {"eq": [1000, 2000]}, "/params/speeds": {"eq": [50, 100]},
"/result_keys/keys": {"contains": "adaptive_pressure_advance_model"}}},
{"tool": "plate_slice", "expect": {"/plates/0/outcome": {"eq": "ok"}}},
{"tool": "calibration_generate_test", "args": {"test": "pressure_advance", "method": "pattern", "discard_changes": true, "preset_changes": "discard"},
"expect": {"/objects": {"eq": 1}, "/params/accelerations/0": {"gt": 0}, "/params/speeds/0": {"gt": 0}}},
// ---- Flow ratio: the four passes ----
{"tool": "calibration_generate_test", "args": {"test": "flow_ratio", "discard_changes": true, "preset_changes": "discard"},
"expect": {"/params": {"eq": {"method": "yolo", "top_surface_pattern": "archimedeanchords"}}, "/objects": {"eq": 11},
"/names/0": {"eq": "flowrate_0"}, "/result_keys/keys": {"eq": ["filament_flow_ratio"]}}},
{"tool": "plate_slice", "expect": {"/plates/0/outcome": {"eq": "ok"}}},
{"tool": "calibration_generate_test", "args": {"test": "flow_ratio", "method": "yolo_perfectionist", "discard_changes": true, "preset_changes": "discard"},
"expect": {"/objects": {"eq": 16}}},
{"tool": "calibration_generate_test", "args": {"test": "flow_ratio", "method": "pass1", "discard_changes": true, "preset_changes": "discard"},
"expect": {"/objects": {"eq": 9}}},
{"tool": "calibration_generate_test", "args": {"test": "flow_ratio", "method": "pass2", "top_surface_pattern": "monotonic", "discard_changes": true, "preset_changes": "discard"},
"expect": {"/objects": {"eq": 10}, "/names/1": {"eq": "flowrate_m1"}, "/params/top_surface_pattern": {"eq": "monotonic"}}},
// ---- Retraction, VFA (with its auto-adjust), input shaping and cornering ----
{"tool": "calibration_generate_test", "args": {"test": "retraction", "end": 1, "discard_changes": true, "preset_changes": "discard"},
"expect": {"/params": {"eq": {"start": 0, "end": 1, "step": 0.1}}, "/names": {"eq": ["retraction_tower.drc"]}}},
{"tool": "plate_slice", "expect": {"/plates/0/outcome": {"eq": "ok"}}},
{"tool": "calibration_generate_test", "args": {"test": "vfa", "discard_changes": true, "preset_changes": "discard"},
"expect": {"/params": {"eq": {"start": 40, "end": 200, "step": 10, "auto_scale": true, "auto_adjust": true}},
"/adjusted": {"exists": false}, "/presets_changed/process/changes/spiral_mode": {"eq": "1"},
"/result_keys/type": {"eq": "printer"}}},
{"tool": "plate_slice", "expect": {"/plates/0/outcome": {"eq": "ok"}}},
{"tool": "calibration_generate_test", "args": {"test": "vfa", "end": 400, "step": 20, "discard_changes": true, "preset_changes": "discard"},
"expect": {"/adjusted/layer_height": {"lt": 0.2}, "/params/end": {"eq": 400}}},
{"tool": "settings_get", "args": {"target": "object", "object": 0, "keys": ["layer_height"]}, "expect": {"/items/0/value": {"ne": "0.2"}}},
{"tool": "calibration_generate_test", "args": {"test": "vfa", "end": 400, "auto_adjust": false, "discard_changes": true, "preset_changes": "discard"},
"expect": {"/adjusted": {"exists": false}, "/warnings/0": {"contains": "maximum volumetric speed"}}},
{"tool": "calibration_generate_test", "args": {"test": "input_shaping_freq", "start": 20, "end": 80, "discard_changes": true, "preset_changes": "discard"},
"expect": {"/params": {"eq": {"start": 20, "end": 80, "start_y": 20, "end_y": 80, "damping": 0.15, "shaper_type": "Default",
"test_model": "ringing_tower"}},
"/names": {"eq": ["ringing_tower.drc"]}, "/result_keys/keys": {"contains": "input_shaping_emit"}}},
{"tool": "calibration_generate_test", "args": {"test": "input_shaping_damp", "freq_x": 48, "freq_y": 42, "test_model": "fast_tower",
"discard_changes": true, "preset_changes": "discard"},
"expect": {"/params/freq_y": {"eq": 42}, "/params/end": {"eq": 0.4}, "/names": {"eq": ["fast_tower_test.drc"]}}},
{"tool": "calibration_generate_test", "args": {"test": "cornering", "test_model": "scv_v2", "end": 25, "discard_changes": true, "preset_changes": "discard"},
"expect": {"/params": {"eq": {"start": 1, "end": 25, "test_model": "scv_v2"}}, "/names": {"eq": ["SCV-V2.drc"]},
"/warnings/0": {"contains": "layer shifts"}, "/result_keys/keys": {"eq": ["machine_max_jerk_x", "machine_max_jerk_y"]}}},
{"tool": "plate_slice", "expect": {"/plates/0/outcome": {"eq": "ok"}}},
// ---- The filament tab on another slot's modified preset: refused with "keep", switched with "discard" ----
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "action_run", "args": {"id": "orca_command:filament_add:orca"}, "expect": {"/message": {"eq": "Added filament slot 2."}}},
{"tool": "settings_set", "args": {"type": "filament", "filament_slot": 2, "values": {"filament_cost": 21}}},
{"tool": "preset_save", "args": {"type": "filament", "name": "MCP Calib PLA", "filament_slot": 2, "overwrite": true}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu PLA Basic @BBL X1C", "filament_slot": 1}},
{"tool": "settings_set", "args": {"type": "filament", "filament_slot": 2, "values": {"filament_cost": 22}}},
{"tool": "calibration_generate_test", "args": {"test": "retraction", "discard_changes": true, "preset_changes": "keep"}, "optional": true},
{"tool": "object_list", "expect": {"/total": {"eq": 0}}},
{"tool": "calibration_generate_test", "args": {"test": "retraction", "discard_changes": true, "preset_changes": "discard"},
"expect": {"/presets_changed/filament/name": {"eq": "Bambu PLA Basic @BBL X1C"},
"/presets_changed/filament/tab_switched_from": {"eq": "MCP Calib PLA"},
"/discarded/filament": {"eq": {"name": "MCP Calib PLA", "keys": ["filament_cost"]}}}},
// ---- "keep" runs the test with an edit, which project_new with "discard" then drops ----
{"tool": "settings_set", "args": {"type": "filament", "values": {"slow_down_layer_time": 7}}},
{"tool": "calibration_generate_test", "args": {"test": "retraction", "discard_changes": true, "preset_changes": "keep"},
"expect": {"/modified/filament/keys": {"contains": "slow_down_layer_time"}, "/discarded": {"exists": false}}},
{"tool": "settings_get", "args": {"type": "filament", "keys": ["slow_down_layer_time"]}, "expect": {"/items/0/value": {"eq": "7"}}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"},
"expect": {"/discarded/filament/keys": {"contains": "slow_down_layer_time"}, "/modified": {"exists": false}}},
{"tool": "settings_get", "args": {"type": "filament", "keys": ["slow_down_layer_time"]}, "expect": {"/items/0/value": {"eq": "4"}}},
// ---- Back to one slot and no MCP presets ----
{"tool": "filament_delete", "args": {"filament_slot": 2}, "expect": {"/level": {"eq": "success"}}},
{"tool": "preset_delete", "args": {"type": "filament", "name": "MCP Calib PLA"}, "expect": {"/deleted": {"eq": "MCP Calib PLA"}}},
{"tool": "preset_list", "args": {"type": "filament"}, "expect": {"/total": {"eq": 1}, "/items/0/modified": {"exists": false}}}
]
}
-74
View File
@@ -1,74 +0,0 @@
// Context and button menus are listed or run by path, never shown, so the run must finish with nobody
// pressing Escape (on macOS a native menu would hold every later step). Run it on a fresh datadir set
// up with the default printer (Bambu Lab X1 Carbon 0.4):
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/context_menus.json --out /tmp/menus
// Refusals (no such item, a submenu, a disabled item, a click that opened no menu) are unit tests in
// tests/slic3rutils/test_mcp_results.cpp, since a replay step cannot expect an error.
{
"orca_replay_version": "0.2.0",
"name": "context menus",
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "dialog_auto_answer", "args": {"rules": [
{"match": "Uniform scale", "button": "ok"},
{"match": "per-object setting mode", "button": "ok"}]}},
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "window_set", "args": {"size": [1600, 900]}},
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "action_run", "args": {"id": "orca_command:add_primitive_cube:orca"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "view_set", "args": {"camera": "iso"}},
// Every click on the cube goes to a point on its top, in the cube's own coordinates, away from the
// diagonal its two triangles share. The middle of the top is on that edge, and from the iso view the
// ray to it runs along the edge, where rounding can let the surface check's ray slip between them.
// ---- A right click on the cube lists the object menu; nothing is shown ----
{"tool": "mouse_gesture", "args": {"action": "click", "button": "right", "at": {"object": 0, "point": [6, -6, 12.8]}},
"expect": {"/popup_menu/items": {"contains": "Add Modifier>Cylinder"}, "/popup_menu/checked": {"contains": "Printable"}}},
{"tool": "app_state", "expect": {"/dialogs": {"empty": true}}},
// ---- The same click runs an item: a modifier through the GUI's own command, one undo step ----
{"tool": "mouse_gesture", "args": {"action": "click", "button": "right", "at": {"object": 0, "point": [6, -6, 12.8]}, "popup_item": "add modifier>cylinder"},
"expect": {"/ran": {"eq": "Add Modifier>Cylinder"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/1/type": {"eq": "modifier"}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/1": {"exists": false}}},
{"tool": "action_run", "args": {"id": "orca_command:redo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/1/type": {"eq": "modifier"}}},
// ---- The Edit menu's Undo and Redo, named by their labels alone on every platform, though macOS shows
// their keys as text after them ----
{"tool": "widget_click", "args": {"target": {"menu": "Edit>Undo"}}, "expect": {"/clicked": {"eq": "Edit>Undo"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/1": {"exists": false}}},
{"tool": "widget_click", "args": {"target": {"menu": "Edit>Redo"}}, "expect": {"/clicked": {"eq": "Edit>Redo"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/1/type": {"eq": "modifier"}}},
// ---- Empty space with nothing selected: the default menu ----
{"tool": "object_select", "args": {"none": true}},
{"tool": "mouse_gesture", "args": {"action": "click", "button": "right", "x": 1000, "y": 150},
"expect": {"/popup_menu/items": {"contains": "Add Primitive>Cube"}}},
{"tool": "mouse_gesture", "args": {"action": "click", "button": "right", "x": 1000, "y": 150, "popup_item": "Add Primitive>Cylinder"},
"expect": {"/ran": {"eq": "Add Primitive>Cylinder"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "app_state", "expect": {"/objects": {"eq": 2}}},
// ---- A button's menu: the first edit button, the printer's (zero-sized on macOS, which froze the
// app before), or on Linux, where that one is hidden, filament 1's, which has a menu with two
// filaments ----
{"tool": "widget_click", "args": {"target": {"label": "Add one filament"}}},
{"tool": "widget_click", "args": {"target": {"label": "Click to edit preset", "index": 0}},
"expect": {"/popup_menu/items": {"empty": false}}},
{"tool": "app_state", "expect": {"/dialogs": {"empty": true}, "/tab": {"eq": "prepare"}}},
// ---- Two objects selected: the multi-selection menu, built for each click and freed after it ----
{"tool": "object_select", "args": {"all": true}},
{"tool": "mouse_gesture", "args": {"action": "click", "button": "right", "at": {"object": 0, "point": [6, -6, 12.8]}},
"expect": {"/popup_menu/items": {"contains": "Align/Distribute>Align left (-X)"}}},
{"tool": "mouse_gesture", "args": {"action": "click", "button": "right", "at": {"object": 0, "point": [6, -6, 12.8]}},
"expect": {"/popup_menu/items": {"contains": "Delete"}}},
{"tool": "mouse_gesture", "args": {"action": "click", "button": "right", "at": {"object": 0, "point": [6, -6, 12.8]}, "popup_item": "Delete"},
"expect": {"/ran": {"eq": "Delete"}}},
{"tool": "app_state", "expect": {"/objects": {"eq": 0}, "/closed_menus": {"empty": true}}}
]
}
-59
View File
@@ -1,59 +0,0 @@
// Auto-answered dialogs run their buttons' handlers, a toolbar item reads the state a selection just
// gave it, and model points on a negative part or seen through the bed from below are click targets.
// Run it on a fresh datadir set up with the default printer (Bambu Lab X1 Carbon 0.4):
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/dialogs_canvas_input.json --out /tmp/dialogs
// Refusals (a point or an ImGui item under a panel or notification) are unit tests in
// tests/slic3rutils/test_mcp_results.cpp, since a replay step cannot expect an error.
{
"orca_replay_version": "0.2.0",
"name": "auto-answers and canvas input",
"vars": {"standard": "0.20mm Standard @BBL X1C", "fine": "0.16mm High Quality @BBL X1C"},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "dialog_auto_answer", "args": {"rules": [
{"match": "Uniform scale", "button": "ok"},
{"match": "unsaved changes", "button": "no"},
{"match": "Transfer or discard", "button": "Transfer"}]}},
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "window_set", "args": {"size": [1600, 900]}},
{"tool": "view_set", "args": {"tab": "prepare"}},
// ---- An auto-answered Transfer keeps the edit on the newly selected process preset ----
{"tool": "preset_select", "args": {"type": "process", "name": "${vars.standard}"}},
{"tool": "settings_set", "args": {"type": "process", "values": {"wall_loops": 5}}},
{"tool": "preset_select", "args": {"type": "process", "name": "${vars.fine}"}, "expect": {"/selected": {"eq": "0.16mm High Quality @BBL X1C"}}},
{"tool": "settings_get", "args": {"type": "process", "keys": ["wall_loops"]}, "expect": {"/items/0/value": {"eq": "5"}}},
// ---- An auto-answered Discard drops it ----
{"tool": "dialog_auto_answer", "args": {"rules": [{"match": "Transfer or discard", "button": "Discard"}]}},
{"tool": "preset_select", "args": {"type": "process", "name": "${vars.standard}"}, "expect": {"/selected": {"eq": "0.20mm Standard @BBL X1C"}}},
{"tool": "settings_get", "args": {"type": "process", "keys": ["wall_loops"]}, "expect": {"/items/0/value": {"ne": "5"}}},
{"tool": "app_state", "expect": {"/project/dirty": {"eq": false}}},
// ---- A toolbar item a selection just enabled takes the click at once ----
{"tool": "action_run", "args": {"id": "orca_command:add_primitive_cube:orca"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "widget_list", "args": {"query": "layersediting"}},
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "widget_click", "args": {"target": {"gltoolbar": "layersediting"}}, "expect": {"/pressed": {"eq": true}}},
{"tool": "widget_click", "args": {"target": {"gltoolbar": "layersediting"}}, "expect": {"/pressed": {"eq": false}}},
// ---- A negative part is a surface target (the text lands on the cube's top) ----
{"tool": "view_set", "args": {"camera": "iso"}},
{"tool": "view_set", "args": {"camera": "fit_objects"}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Text"}}, "expect": {"/created": {"eq": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "widget_click", "args": {"target": {"imgui": "Cut"}}},
{"tool": "widget_click", "args": {"target": {"imgui": "Done"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/1/type": {"eq": "negative"}}},
// The text's size, and so which of its ends the cube hides, differs between platforms; the step is
// about the part resolving as a target, so it skips the visibility check.
{"tool": "mouse_gesture", "args": {"action": "move", "at": {"object": 0, "part": 1, "spot": "right"}, "check": "point"}},
// ---- From below, the bed hides nothing ----
{"tool": "view_set", "args": {"camera": "bottom"}},
{"tool": "view_set", "args": {"camera": "fit_objects"}},
{"tool": "mouse_gesture", "args": {"action": "move", "at": {"object": 0, "spot": "bottom"}}},
{"tool": "mouse_gesture", "args": {"action": "move", "at": {"object": 0, "point": [5, 5, -12.8]}}}
]
}
-141
View File
@@ -1,141 +0,0 @@
// Filament slots, exports of some objects, and imports from a ZIP archive and a STEP file, by index: filament_delete
// merges slot 2 into slot 1, and the object on slot 2 prints with slot 1; filament_add_mixed mixes slots 1 and 2 into a
// new slot, which its reply and project_get_settings name, and the same mix again names that slot; project_export writes
// object 0 alone as an STL, each object as an STL of its own into a folder, both as one DRC and each as a DRC of its
// own, and after a slice the Preview's toolpaths as an OBJ, and a script reads the files' sizes
// (fixtures/filaments_and_files.py, whose files are in the configuration folder a script may write); project_import
// takes the entries named from a ZIP archive written there, then all of its model files, and from a ZIP that holds one
// project file the objects of that project, which it adds to those there without a question. A STEP file's
// mesh options open when project_import, part_add and part_replace read it (ruling 16): each call replies
// blocked_by_dialog, the dialog is answered, and the call's job is waited for.
// Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/filaments_and_files.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "filaments and files by index",
"vars": {
"files": "${replay_dir}/fixtures/filaments_and_files.py",
"undo": "${replay_dir}/fixtures/ops_undo.py",
"step": "${replay_dir}/../../../tests/data/named_single_body.step"
},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "view_set", "args": {"tab": "prepare"}},
// ---- Filament slots: slot 2 merged into slot 1, the object on it following ----
{"tool": "filament_add", "expect": {"/filament_slot": {"eq": 2}, "/filament_slots": {"eq": 2}}},
{"tool": "filament_add", "expect": {"/filament_slot": {"eq": 3}, "/filament_slots": {"eq": 3}}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20], "name": "on_two"}},
{"tool": "settings_set", "args": {"target": "object", "object": 0, "values": {"extruder": 2}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/filament": {"eq": 2}}},
{"tool": "filament_delete", "args": {"filament_slot": 2, "merge_into": 1},
"expect": {"/filament_slot": {"eq": 2}, "/merged_into": {"eq": 1}, "/filament_slots": {"eq": 2}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/filament": {"eq": 1}}},
// ---- A mixed filament of slots 1 and 2, in a slot after them ----
{"tool": "filament_add_mixed", "args": {"components": [1, 2], "ratios": [50, 50]},
"expect": {"/filament_slot": {"eq": 3}, "/added": {"eq": true}}},
{"tool": "project_get_settings", "args": {"keys": ["filament_is_mixed"]}, "expect": {"/items/0/value": {"eq": "0,0,1"}}},
{"tool": "app_state", "expect": {"/presets/filaments/2": {"exists": true}, "/presets/filaments/3": {"exists": false}}},
{"tool": "filament_add_mixed", "args": {"components": [1, 2], "ratios": [50, 50]},
"expect": {"/filament_slot": {"eq": 3}, "/added": {"eq": false}}},
{"tool": "app_state", "expect": {"/presets/filaments/3": {"exists": false}}},
// ---- Exports: object 0 alone as an STL, each object as an STL of its own, both as one DRC ----
// A cube's binary STL is 84 bytes and 50 a triangle: 684 bytes for one cube's 12 triangles, 1284 for two cubes.
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20], "name": "small"}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [30, 30, 30], "name": "big"}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import filaments_and_files\nresult = filaments_and_files.export(args)",
"args": {"name": "small.stl", "format": "stl", "objects": [0]}},
"expect": {"/result/reply/objects/0/name": {"eq": "small"}, "/result/reply/objects/1": {"exists": false},
"/result/reply/bytes": {"eq": 684}, "/result/sizes/small.stl": {"eq": 684}}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import filaments_and_files\nresult = filaments_and_files.export(args)",
"args": {"name": "both.stl", "format": "stl"}},
"expect": {"/result/reply/objects/1/name": {"eq": "big"}, "/result/sizes/both.stl": {"eq": 1284}}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import filaments_and_files\nresult = filaments_and_files.export(args)",
"args": {"name": "each", "format": "stl", "per_object": true}},
"expect": {"/result/reply/files/1": {"exists": true}, "/result/reply/files/2": {"exists": false},
"/result/reply/objects/1/name": {"eq": "big"}, "/result/reply/bytes": {"exists": false},
"/result/sizes/small.stl": {"eq": 684}, "/result/sizes/big.stl": {"eq": 684}}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import filaments_and_files\nresult = filaments_and_files.export(args)",
"args": {"name": "both.drc", "format": "drc"}},
"expect": {"/result/reply/objects/1/name": {"eq": "big"}, "/result/reply/bytes": {"gt": 0}, "/result/sizes/both.drc": {"gt": 0}}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import filaments_and_files\nresult = filaments_and_files.export(args)",
"args": {"name": "each_drc", "format": "drc", "per_object": true}},
"expect": {"/result/reply/files/1": {"exists": true}, "/result/reply/files/2": {"exists": false},
"/result/sizes/small.drc": {"gt": 0}, "/result/sizes/big.drc": {"gt": 0}}},
// The toolpaths the Preview shows, once the plate is sliced and shown there.
{"tool": "plate_slice", "args": {"preview": true}, "expect": {"/plates/0/outcome": {"eq": "ok"}}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import filaments_and_files\nresult = filaments_and_files.export(args)",
"args": {"name": "toolpaths.obj", "format": "toolpaths_obj"}},
"expect": {"/result/reply/bytes": {"gt": 0}, "/result/sizes/toolpaths.obj": {"gt": 0}}},
{"tool": "view_set", "args": {"tab": "prepare"}},
// ---- A ZIP archive: the entries named, then every model file; a text file beside them is no model ----
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import filaments_and_files\nresult = filaments_and_files.write_zip(args)",
"args": {"name": "cubes.zip", "cubes": {"small.stl": 10, "parts/middle.stl": 15, "parts/large.stl": 20}}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import filaments_and_files\nresult = filaments_and_files.import_zip(args)",
"args": {"name": "cubes.zip", "entries": ["small.stl", "parts/large.stl"]}},
"expect": {"/result/added": {"eq": 2}, "/result/archives/0/entries": {"eq": ["small.stl", "parts/large.stl"]},
"/result/archives/1": {"exists": false}}},
// The loader adds the files taken in the order of their names.
{"tool": "object_list", "expect": {"/total": {"eq": 2}, "/plates/0/objects/0/name": {"eq": "large.stl"},
"/plates/0/objects/0/parts/0/mesh_volume": {"eq": 8000},
"/plates/0/objects/1/name": {"eq": "small.stl"},
"/plates/0/objects/1/parts/0/mesh_volume": {"eq": 1000}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"},
"expect": {"/result/taken": {"eq": ["Import Objects: cubes.zip"]}}},
{"tool": "app_state", "expect": {"/dialogs": {"empty": true}}},
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import filaments_and_files\nresult = filaments_and_files.import_zip(args)",
"args": {"name": "cubes.zip"}},
"expect": {"/result/added": {"eq": 3}, "/result/archives/0/entries/2": {"exists": true},
"/result/archives/0/entries/3": {"exists": false}}},
{"tool": "object_list", "expect": {"/total": {"eq": 3}}},
// ---- A ZIP that holds one project file: its objects join those there, as a .3mf in paths gives them ----
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [10, 10, 10], "name": "inside_zip"}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import filaments_and_files\nresult = filaments_and_files.write_project_zip(args)",
"args": {"name": "project.zip"}}},
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20], "name": "first"}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [30, 30, 30], "name": "second"}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import filaments_and_files\nresult = filaments_and_files.import_zip(args)",
"args": {"name": "project.zip"}},
"expect": {"/result/added": {"eq": 1}, "/result/archives/0/entries": {"eq": ["project.3mf"]}}},
{"tool": "object_list", "expect": {"/total": {"eq": 3}, "/plates/0/objects/0/name": {"eq": "first"},
"/plates/0/objects/1/name": {"eq": "second"},
"/plates/0/objects/2/name": {"eq": "inside_zip"}}},
{"tool": "app_state", "expect": {"/dialogs": {"empty": true}, "/project/path": {"eq": ""}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"},
"expect": {"/result/taken": {"eq": ["Import Objects: project.zip"]}}},
// ---- A STEP file's mesh options open for project_import, part_add and part_replace, and are answered ----
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "project_import", "args": {"paths": ["${vars.step}"]}, "await": false, "save_as": "step_import"},
{"tool": "app_wait", "args": {"for": "dialog"}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "STEP file import parameters"}, "button": "ok"}},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.step_import}"}},
{"tool": "object_list", "expect": {"/total": {"eq": 1}, "/plates/0/objects/0/parts/0": {"exists": true},
"/plates/0/objects/0/parts/1": {"exists": false}}},
{"tool": "part_add", "args": {"object": 0, "type": "part", "path": "${vars.step}"}, "await": false, "save_as": "step_part"},
{"tool": "app_wait", "args": {"for": "dialog"}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "STEP file import parameters"}, "button": "ok"}},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.step_part}"}},
{"tool": "object_list", "expect": {"/total": {"eq": 1}, "/plates/0/objects/0/parts/1": {"exists": true}}},
{"tool": "part_replace", "args": {"object": 0, "part": 1, "path": "${vars.step}"}, "await": false, "save_as": "step_replace"},
{"tool": "app_wait", "args": {"for": "dialog"}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "STEP file import parameters"}, "button": "ok"}},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.step_replace}"}},
{"tool": "object_list", "expect": {"/total": {"eq": 1}, "/plates/0/objects/0/parts/1": {"exists": true},
"/plates/0/objects/0/parts/2": {"exists": false}}},
{"tool": "app_state", "expect": {"/dialogs": {"empty": true}}},
{"tool": "project_new", "args": {"discard_changes": true}}
]
}
+6 -48
View File
@@ -1,15 +1,14 @@
"""Files for the filaments_and_files replay, run with script_run:
"""Files for test_additions_refusals.py, run with script_run:
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/filaments_and_files.py",
"code": "import filaments_and_files\nresult = filaments_and_files.export(args)",
"args": {"name": "first.stl", "format": "stl", "objects": [0]}}}
client.call("script_run", filename=".../fixtures/filaments_and_files.py",
code="import filaments_and_files\nresult = filaments_and_files.write_zip(args)",
args={"name": "cubes.zip", "cubes": {"a.stl": 10}})
A script's own files are held to OrcaSlicer's configuration folder unless scripts run unrestricted, so the files go in
<datadir>/mcp/filaments_and_files/, which every run of the sweep has to itself, and the functions that write or read a
file call the command that takes its path themselves. Each returns what it did as a dict, which the step's result keeps.
<datadir>/mcp/filaments_and_files/, which every run of the sweep has to itself. Each function returns what it did as a
dict, which the run's result keeps.
"""
import os
import shutil
import zipfile
import orca
@@ -41,28 +40,6 @@ def cube_stl(size):
return "\n".join(lines) + "\n"
def export(args):
"""project_export into the folder: of args["format"] as the file args["name"], or with args["per_object"] into the
subfolder args["name"], emptied first, of the objects args["objects"] when given. Returns the reply and the size of
each file written, by its name."""
path = os.path.join(folder(), args["name"])
request = {"format": args["format"], "path": path}
if args.get("per_object"):
shutil.rmtree(path, ignore_errors=True)
os.makedirs(path)
request["per_object"] = True
elif os.path.exists(path):
os.remove(path)
if "objects" in args:
request["objects"] = args["objects"]
reply = call("project_export", request)
if args.get("per_object"):
sizes = {name: os.path.getsize(os.path.join(path, name)) for name in sorted(os.listdir(path))}
else:
sizes = {args["name"]: os.path.getsize(path)}
return {"reply": reply, "sizes": sizes}
def write_zip(args):
"""Writes the archive args["name"] of cubes, each entry of args["cubes"] ({entry: size in mm}) an STL, with a
text file beside them that is no model. Returns its path."""
@@ -72,22 +49,3 @@ def write_zip(args):
archive.writestr(entry, cube_stl(size))
archive.writestr("readme.txt", "not a model\n")
return {"path": path}
def write_project_zip(args):
"""Writes the project as it is as a 3MF and puts it alone into the archive args["name"] of the folder, as the entry
project.3mf. Returns the archive's path."""
three_mf = os.path.join(folder(), "project.3mf")
call("project_export", {"format": "3mf", "path": three_mf, "overwrite": True})
path = os.path.join(folder(), args["name"])
with zipfile.ZipFile(path, "w") as archive:
archive.write(three_mf, "project.3mf")
return {"path": path}
def import_zip(args):
"""project_import of the archive args["name"] of the folder, with args["entries"] when given; returns the reply."""
request = {"paths": [os.path.join(folder(), args["name"])]}
if "entries" in args:
request["entries"] = args["entries"]
return call("project_import", request)
-122
View File
@@ -1,122 +0,0 @@
"""Model files for the objects_state and objects_files replays, run with script_run:
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/objects_files.py",
"code": "import objects_files\nresult = objects_files.import_cube(args)",
"args": {"name": "open.stl", "size": 20, "holed": true}}}
A script's own files are held to OrcaSlicer's configuration folder unless scripts run unrestricted, so the files go in
<datadir>/mcp/objects_files/, which every run of the sweep has to itself, and the functions that need a file's path
import it themselves. Each returns what it did as a dict, which the step's result keeps.
"""
import os
import time
import orca
call = orca.host.tools.call
# The corners of a cube and its twelve triangles, each turned outward; the last is the one a holed cube lacks.
CORNERS = [(0, 0, 0), (1, 0, 0), (1, 1, 0), (0, 1, 0), (0, 0, 1), (1, 0, 1), (1, 1, 1), (0, 1, 1)]
TRIANGLES = [(0, 2, 1), (0, 3, 2), (4, 5, 6), (4, 6, 7), (0, 1, 5), (0, 5, 4),
(1, 2, 6), (1, 6, 5), (2, 3, 7), (2, 7, 6), (3, 0, 4), (3, 4, 7)]
def folder():
"""<datadir>/mcp/objects_files, created when missing; the app's log is in <datadir>/log."""
log = call("app_log", {"lines": 1})["file"]
path = os.path.join(os.path.dirname(os.path.dirname(log)), "mcp", "objects_files")
os.makedirs(path, exist_ok=True)
return path
def write_cube(args):
"""Writes an ASCII STL of a cube of args["size"] mm as args["name"], without one triangle when args["holed"],
which leaves three open edges. Returns its path."""
size = float(args.get("size", 20))
triangles = TRIANGLES[:-1] if args.get("holed") else TRIANGLES
path = os.path.join(folder(), args["name"])
lines = ["solid cube"]
for triangle in triangles:
lines += [" facet normal 0 0 0", " outer loop"]
lines += [" vertex %g %g %g" % tuple(c * size for c in CORNERS[i]) for i in triangle]
lines += [" endloop", " endfacet"]
lines.append("endsolid cube")
with open(path, "w") as f:
f.write("\n".join(lines) + "\n")
return {"path": path}
def import_cube(args):
"""Writes the cube write_cube() writes and imports it with project_import; returns the path and the reply."""
path = write_cube(args)["path"]
return {"path": path, "import": call("project_import", {"paths": [path]})}
def repair_notices():
"""The notifications Fix Model's menu item ends in (the object list's fix_through_cgal()), and the open dialogs.
The object info notification of a selected object, which offers Fix Model, is not one."""
state = call("app_state", {})
ends = ("has been repaired", "have been repaired", "needed no repair", "Failed to repair", "Repairing was canceled")
notices = [n["text"] for n in state["notifications"] if any(end in n["text"] for end in ends)]
return {"notices": notices, "dialogs": [d.get("title") for d in state["dialogs"]]}
def mesh_errors(index):
"""Object `index`'s mesh errors as object_list gives them."""
listing = call("object_list", {})
rows = [row for plate in listing["plates"] for row in plate["objects"]] + listing.get("outside", [])
return next(row["mesh_errors"] for row in rows if row["index"] == index)
def wait_repaired(args):
"""Waits up to 30 s for object args["object"] to have no open edge and for Fix Model's notification, since the
command of a menu item that a mouse_gesture picks runs after the gesture's reply, and its progress dialog lets
calls in while it repairs, before the notification is pushed; returns its mesh errors and repair_notices()."""
deadline = time.monotonic() + 30
errors = mesh_errors(args["object"])
notices = repair_notices()
while (errors["open_edges"] > 0 or not notices["notices"]) and time.monotonic() < deadline:
time.sleep(0.2)
errors = mesh_errors(args["object"])
notices = repair_notices()
return {"mesh_errors": errors, **notices}
def remove(args):
"""Deletes the file args["name"] of the folder; returns whether it was there."""
path = os.path.join(folder(), args["name"])
there = os.path.exists(path)
if there:
os.remove(path)
return {"path": path, "removed": there}
def replace_part(args):
"""part_replace of part args["part"] of object args["object"] with the file args["name"] of the folder."""
path = os.path.join(folder(), args["name"])
return call("part_replace", {"object": args["object"], "part": args["part"], "path": path})
def part_row(index, part):
"""Part `part` of object `index` as object_list gives it."""
listing = call("object_list", {})
rows = [row for plate in listing["plates"] for row in plate["objects"]] + listing.get("outside", [])
return next(row for row in rows if row["index"] == index)["parts"][part]
def replace_keeps(args):
"""part_replace of part args["part"] of object args["object"] with the file args["path"]; returns the reply, and
whether the part kept its type and filament and how far it moved, from object_list before and after."""
before = part_row(args["object"], args["part"])
reply = call("part_replace", {"object": args["object"], "part": args["part"], "path": args["path"]})
after = part_row(args["object"], reply["parts"][0]["part"])
return {"reply": reply, "same_id": after["id"] == before["id"],
"same_type": after["type"] == before["type"], "type": after["type"],
"same_filament": after.get("filament") == before.get("filament"), "filament": after.get("filament"),
"moved": max(abs(a - b) for a, b in zip(after["position"], before["position"]))}
def object_count():
"""How many objects object_list lists, on the plates and off them."""
listing = call("object_list", {})
return {"count": sum(len(plate["objects"]) for plate in listing["plates"]) + len(listing.get("outside", []))}
+5 -112
View File
@@ -1,120 +1,13 @@
"""Helpers for the ops_select_preset and ops_assign_filament_preset replays, run with script_run:
"""The plugin API's preset editors called from a script, for test_operation_routes.py, run with script_run:
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py",
"code": "import ops_presets\nresult = ops_presets.probe()"}}
client.call("script_run", filename=".../fixtures/ops_presets.py",
code="import ops_presets\nresult = ops_presets.preset_api(args)", args={...})
A run whose filename is an existing file imports the modules beside it, so the replays share one copy of each
helper. Each returns what it saw as a dict, which the step's result keeps. A call into the plugin API that raises
is reported by its exception's type and message rather than failing the step.
A call into the plugin API that raises is reported by its exception's type and message, as data the test compares,
rather than failing the run.
"""
import orca
try:
import ops_undo
except ImportError: # ops_undo.py reads the undo snapshots from the log; without it they are not reported
ops_undo = None
call = orca.host.tools.call
# Filament colours and a flushing volume no preset or calculation gives, so a probe shows what a call wrote.
SENTINEL_COLOURS = ["#111111", "#222222", "#333333", "#444444"]
SENTINEL_FLUSH = 777
def _name(preset):
return preset.name + (" (modified)" if preset.is_dirty else "")
def _undo():
return ops_undo.taken()["taken"] if ops_undo is not None else "ops_undo.py missing"
def probe():
"""What a call left: the slot mapping, the preset each tab edits, the three filament colour settings that
PlaterPresetComboBox::update_ams_color() writes, the project's colours and flushing volumes, the open
dialogs, the project's dirty flag and the undo snapshots taken since the last probe or arrange."""
bundle = orca.host.preset_bundle()
state = call("app_state", {})
project = call("project_get_settings", {"keys": ["filament_colour", "flush_volumes_matrix"],
"include_meta": False})
return {
"slots": bundle.current_filament_preset_names(),
"filament_tab": _name(bundle.filaments.edited_preset()),
"process_tab": _name(bundle.prints.edited_preset()),
"printer_tab": _name(bundle.printers.edited_preset()),
"filament_colour": bundle.full_config_value("filament_colour"),
"filament_colour_type": bundle.full_config_value("filament_colour_type"),
"filament_multi_colour": bundle.full_config_value("filament_multi_colour"),
"project": {item["key"]: item["value"] for item in project["items"]},
"dialogs": [dialog.get("title") for dialog in state["dialogs"]],
"project_dirty": state["project"]["dirty"],
"undo_taken": _undo(),
}
def drop_filament_edits():
"""Drops the unsaved changes of the filament preset the tab edits. settings_set reaches the filament tab
through a slot (slot 1 by default) and switches the tab to that slot's preset first, which asks about
the changes, so it is given the slot that holds the edited preset; when no slot holds it, the question
that opens is answered with Discard."""
bundle = orca.host.preset_bundle()
edited = bundle.filaments.edited_preset()
if not edited.is_dirty:
return
names = bundle.current_filament_preset_names()
slot = names.index(edited.name) + 1 if edited.name in names else 1
reply = call("settings_set", {"type": "filament", "filament_slot": slot, "reset_all": True})
if isinstance(reply, dict) and reply.get("status") == "blocked_by_dialog":
call("dialog_answer", {"button": "Discard"})
call("app_wait", {"for": "job", "job": reply["job"]})
def arrange_filaments(args):
"""The state a filament case starts from. args: slots (each slot's preset, by the name its selector shows;
the slot count must already match), tab_slot (1-based: the filament tab edits that slot's preset, default
1), dirty (an unsaved slow_down_layer_time on the preset the tab edits). Colours and flushing volumes are
set to the sentinels. The slot presets are assigned with preset_select and the tab switched with
settings_set filament_slot, both after the edits are dropped, so no prompt opens."""
bundle = orca.host.preset_bundle()
wanted = args["slots"]
if len(bundle.current_filament_preset_names()) != len(wanted):
raise RuntimeError("the project has %d slots, the case wants %d"
% (len(bundle.current_filament_preset_names()), len(wanted)))
drop_filament_edits()
for slot, name in enumerate(wanted, 1):
call("preset_select", {"type": "filament", "name": name, "filament_slot": slot})
call("settings_set", {"type": "filament", "filament_slot": args.get("tab_slot", 1), "reset_all": True})
n = len(wanted)
matrix = [0 if i == j else SENTINEL_FLUSH for i in range(n) for j in range(n)]
call("project_set_settings", {"values": {"filament_colour": SENTINEL_COLOURS[:n],
"flush_volumes_matrix": matrix}})
if args.get("dirty"):
call("settings_set", {"type": "filament", "values": {"slow_down_layer_time": 9}})
call("app_wait", {"for": "idle"})
_undo()
return probe()
def arrange_presets(args):
"""The state a printer or process case starts from. args: printer, process (names), dirty ("process": an
unsaved wall_loops; "printer": unsaved printer notes). Every preset's edits are dropped first."""
drop_filament_edits()
for preset_type in ("process", "printer"):
call("settings_set", {"type": preset_type, "reset_all": True})
bundle = orca.host.preset_bundle()
if bundle.printers.edited_preset().name != args["printer"]:
call("preset_select", {"type": "printer", "name": args["printer"], "preset_changes": "discard"})
if bundle.prints.edited_preset().name != args["process"]:
call("preset_select", {"type": "process", "name": args["process"], "preset_changes": "discard"})
dirty = args.get("dirty")
if dirty == "process":
call("settings_set", {"type": "process", "values": {"wall_loops": 5}})
elif dirty == "printer":
call("settings_set", {"type": "printer", "values": {"printer_notes": "MCP pin"}})
call("app_wait", {"for": "idle"})
_undo()
return probe()
def _transaction(t):
return {"target_name": t.target_name, "selection_changed": t.selection_changed, "slot_number": t.slot_number,
-67
View File
@@ -1,67 +0,0 @@
"""Checks over whole preset lists for the presets_and_plate_map replay, run with script_run:
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/presets_and_plate_map.py",
"code": "import presets_and_plate_map\nresult = presets_and_plate_map.listed(args)",
"args": {"type": "filament", "filament_type": "PLA", "vendor": "Bambu Lab"}}}
A replay's expectations read single values, and these checks hold for every item of a list, so each function reads
every page of a preset_list and returns what it found as a dict, which the step's result keeps.
"""
import orca
call = orca.host.tools.call
def items(args):
"""Every item preset_list gives for `args`, page by page."""
out = []
while True:
reply = call("preset_list", dict(args, limit=500, offset=len(out)))
out += reply["items"]
if not reply["items"] or len(out) >= reply["total"]:
return out
def listed(args):
"""preset_list for `args`: how many items, their names, the names of those that do not match its vendor,
filament_type or source, or lack a field their type gives (a filament its vendor and filament_type, a system
printer its vendor, printer_model and nozzle), and how many are the Template vendor's."""
found = items(args)
fields = {"filament": ["vendor", "filament_type"], "printer": ["vendor", "printer_model", "nozzle"]}.get(args["type"], [])
filters = [key for key in ("vendor", "filament_type") if key in args]
others = []
for item in found:
matches = all(str(item.get(key, "")).lower() == str(args[key]).lower() for key in filters)
source = args.get("source")
if source == "system":
matches = matches and item.get("system", False)
elif source == "user":
matches = matches and item.get("user", False) and not item.get("project", False)
elif source == "project":
matches = matches and item.get("project", False)
if args["type"] == "filament" or item.get("system", False):
matches = matches and all(key in item for key in fields)
if not matches:
others.append(item["name"])
return {"count": len(found), "names": [item["name"] for item in found], "others": others,
"template": sum(1 for item in found if str(item.get("vendor", "")).lower() == "template")}
def fitting(args):
"""The filaments that fit the printer preset args["printer"], against those that fit the selected printer, installed
or not: how many each lists, how many only one of them lists, and how many of the first are marked incompatible."""
other = items({"type": "filament", "printer": args["printer"], "include_uninstalled": True})
selected = items({"type": "filament", "include_uninstalled": True})
other_names = {item["name"] for item in other}
selected_names = {item["name"] for item in selected}
return {"other": len(other), "selected": len(selected), "only_other": len(other_names - selected_names),
"only_selected": len(selected_names - other_names),
"marked_incompatible": sum(1 for item in other if item.get("compatible") is False)}
def refused(args):
"""Calls args["tool"] with args["args"]: the error's message when it is refused, else the reply."""
try:
return {"refused": False, "reply": call(args["tool"], args["args"])}
except Exception as e:
return {"refused": True, "message": str(e)}
-53
View File
@@ -1,53 +0,0 @@
"""Checks over whole settings lists for the settings_targets replay, run with script_run:
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/settings_targets.py",
"code": "import settings_targets\nresult = settings_targets.listing(args)",
"args": {"type": "process"}}}
A replay's expectations read single values, and these checks hold for every item of a list or compare two lists, so
each function reads what it needs and returns what it found as a dict, which the step's result keeps.
"""
import orca
call = orca.host.tools.call
def values(args):
"""settings_list for `args`, which comes whole: {key: value}."""
return {item["key"]: item["value"] for item in call("settings_list", args)["items"]}
def listing(args):
"""settings_list for `args` with no limit: its total, how many items it holds and whether it has a next page."""
reply = call("settings_list", args)
return {"total": reply["total"], "items": len(reply["items"]), "next_offset": "next_offset" in reply}
def value_of(args):
"""The value of `args["key"]` in settings_list for the other arguments."""
query = dict(args)
key = query.pop("key")
return {"value": values(query).get(key)}
def nested(args):
"""Whether the object list holds process settings with the process's values, and the region list the object list's
settings but layer_height, whose item says a height range alone takes it."""
process = values({"type": "process"})
region_items = call("settings_list", {"type": "region"})["items"]
objects = values({"type": "object"})
regions = {item["key"]: item["value"] for item in region_items}
layer_height = [item for item in region_items if item["key"] == "layer_height"]
return {"object": len(objects), "region": len(regions), "process": len(process),
"object_not_in_process": [key for key in objects if key not in process],
"object_values_not_the_process": [key for key in objects if key in process and objects[key] != process[key]],
"region_not_in_object": [key for key in regions if key != "layer_height" and key not in objects],
"layer_height_targets": layer_height[0].get("targets") if layer_height else None}
def overrides(args):
"""settings_get with `args` (a target and no keys): {key: value} of what the target overrides, and the reply's
naming of the target."""
reply = call("settings_get", args)
named = {key: reply[key] for key in ("objects", "parts", "height_range") if key in reply}
return {"values": {item["key"]: item["value"] for item in reply["items"]}, "named": named}
-326
View File
@@ -1,326 +0,0 @@
// Drives every gizmo the way a person does, through the generic GUI tools (gizmo icons, panel fields
// by label or name, clicks at points of the model), and checks what each one leaves on the model.
// Each section undoes and redoes its change and takes a canvas screenshot. Run it on a fresh datadir:
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/gizmos.json --out /tmp/gizmos
// and again at another window size, through replay_run's vars:
// tools/mcp/orca_mcp.py call replay_run '{"path": "/abs/tools/mcp/tests/gizmos.json",
// "out_dir": "/tmp/gizmos-small", "vars": {"window_size": [1100, 760]}}' --wait
{
"orca_replay_version": "0.2.0",
"name": "every gizmo",
"vars": {
"window_size": [1600, 900],
"svg": "${replay_dir}/fixtures/star.svg",
"heightmap": "${replay_dir}/fixtures/heightmap.png"
},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "dialog_auto_answer", "args": {"rules": [
{"match": "Uniform scale", "button": "ok"},
{"match": "discard current style modification", "button": "yes"},
{"match": "unsaved changes", "button": "no"},
{"match": "text volume is empty", "button": "ok"}]}},
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "action_run", "args": {"id": "orca_command:mode_expert:orca"}},
{"tool": "window_set", "args": {"size": "${vars.window_size}"}},
{"tool": "view_set", "args": {"tab": "prepare"}},
// Two filaments, so Color Painting is offered.
{"tool": "widget_click", "args": {"target": {"label": "Add one filament"}}},
{"tool": "app_state", "expect": {"/presets/filaments/1": {"exists": true}}},
// Object 0 and object 1: two 25.6 mm cubes (the default size on this bed), moved with their
// centres 12.8 mm up so they stand on the bed.
{"tool": "action_run", "args": {"id": "orca_command:add_primitive_cube:orca"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "action_run", "args": {"id": "orca_command:add_primitive_cube:orca"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_transform", "args": {"object": 0, "translate": [100, 100, 12.8], "mode": "absolute"}},
{"tool": "object_transform", "args": {"object": 1, "translate": [160, 100, 12.8], "mode": "absolute"}},
// A gesture that fails ends a press held from before it.
{"tool": "mouse_gesture", "args": {"action": "down", "button": "middle", "x": 300, "y": 300}, "expect": {"/held": {"eq": true}}},
{"tool": "mouse_gesture", "args": {"action": "move", "at": {"object": 0, "point": [0, 0, 5000], "frame": "world"}}, "optional": true},
{"tool": "mouse_gesture", "args": {"action": "move", "x": 310, "y": 300}, "expect": {"/held": {"exists": false}}},
{"tool": "view_set", "args": {"camera": "iso"}},
{"tool": "view_set", "args": {"camera": "fit_objects"}},
{"tool": "object_list", "expect": {"/total": {"eq": 2}}},
// ---- Move: opens, a field sets X, the coordinate combo switches, a second click closes ----
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Move"}}, "expect": {"/active": {"eq": true}}},
{"tool": "app_state", "expect": {"/gizmo/name": {"eq": "Move"}}},
{"tool": "widget_set_value", "args": {"target": {"imgui": "Position", "window": "Object operations"}, "value": 90}, "expect": {"/value": {"eq": "90.00"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/instances/0/offset/0": {"eq": 90}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/instances/0/offset/0": {"eq": 100}}},
{"tool": "action_run", "args": {"id": "orca_command:redo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/instances/0/offset/0": {"eq": 90}}},
{"tool": "widget_set_value", "args": {"target": {"imgui_name": "coordinates"}, "value": "Object"}, "expect": {"/selected": {"eq": "Object"}}},
{"tool": "widget_set_value", "args": {"target": {"imgui_name": "coordinates"}, "value": 0}, "expect": {"/selected": {"eq": "World"}}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/move.png", "overwrite": true, "include_image": false}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Move"}}, "expect": {"/active": {"eq": false}}},
{"tool": "app_state", "expect": {"/gizmo": {"eq": null}}},
// ---- Move's alignment: both cubes to the same front edge ----
{"tool": "object_select", "args": {"all": true}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Move"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "Align front"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/1/instances/0/offset/1": {"eq": 100}}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Move"}}},
// ---- Rotate: the absolute Z angle ----
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Rotate"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_set_value", "args": {"target": {"imgui_name": "absolute_rotation_z"}, "value": 30}, "expect": {"/value": {"eq": "30.00"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/instances/0/rotation_deg/2": {"gt": 29.9}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "action_run", "args": {"id": "orca_command:redo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/instances/0/rotation_deg/2": {"gt": 29.9}}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/rotate.png", "overwrite": true, "include_image": false}},
{"tool": "widget_set_value", "args": {"target": {"imgui_name": "absolute_rotation_z"}, "value": 0}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Rotate"}}, "expect": {"/active": {"eq": false}}},
// ---- Scale: uniform scale by the X field ----
{"tool": "widget_click", "args": {"target": {"gizmo": "Scale"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_set_value", "args": {"target": {"imgui": "Scale"}, "value": 120}, "expect": {"/value": {"eq": "120.00"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/instances/0/scale/2": {"gt": 1.19}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/instances/0/scale/2": {"eq": 1}}},
{"tool": "action_run", "args": {"id": "orca_command:redo:orca"}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/scale.png", "overwrite": true, "include_image": false}},
{"tool": "widget_set_value", "args": {"target": {"imgui": "Scale"}, "value": 100}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Scale"}}, "expect": {"/active": {"eq": false}}},
// ---- Flatten: object 1 laid on its front face ----
{"tool": "object_select", "args": {"objects": [1]}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Flatten"}}, "expect": {"/active": {"eq": true}}},
{"tool": "mouse_gesture", "args": {"at": {"object": 1, "spot": "front"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/1/instances/0/rotation_deg/0": {"gt": 89}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/1/instances/0/rotation_deg/0": {"lt": 1}}},
{"tool": "action_run", "args": {"id": "orca_command:redo:orca"}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/flatten.png", "overwrite": true, "include_image": false}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Flatten"}}},
// ---- Supports: a stroke on the top, Fill on the front, seen through object 1 where it would hide the front ----
{"tool": "object_transform", "args": {"object": 1, "translate": [100, 60, 12.8], "mode": "absolute"}},
{"tool": "view_set", "args": {"camera": "front"}},
{"tool": "view_set", "args": {"camera": "fit_objects"}},
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "widget_click", "args": {"target": {"gizmo": "FdmSupports"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "Fill"}}},
// Object 1 stands in front of object 0's front face; the gizmo hides it, so the point is clickable.
{"tool": "mouse_gesture", "args": {"at": {"object": 0, "spot": "front"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/supports/enforcers": {"gt": 0}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted": {"exists": false}}},
{"tool": "action_run", "args": {"id": "orca_command:redo:orca"}},
{"tool": "view_set", "args": {"camera": "iso"}},
{"tool": "view_set", "args": {"camera": "fit_objects"}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "Circle"}}},
{"tool": "widget_set_value", "args": {"target": {"imgui": "Brush size"}, "value": 3}, "expect": {"/value": {"eq": "3.00"}}},
{"tool": "mouse_gesture", "args": {"action": "drag", "button": "right", "at": {"object": 0, "spot": "top"}, "to": {"object": 0, "point": [6, 6, 12.8]}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/supports/blockers": {"gt": 0}}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/supports.png", "overwrite": true, "include_image": false}},
{"tool": "widget_click", "args": {"target": {"imgui": "Done"}}},
// Painted enforcers with support off raise a lasting warning, whose notification can cover a later
// panel's items in a small window (a click there is refused); support goes on, as it asks.
{"tool": "settings_set", "args": {"type": "process", "values": {"enable_support": true}}},
{"tool": "object_transform", "args": {"object": 1, "translate": [160, 100, 12.8], "mode": "absolute"}},
// ---- Seam ----
{"tool": "widget_click", "args": {"target": {"gizmo": "Seam"}}, "expect": {"/active": {"eq": true}}},
{"tool": "mouse_gesture", "args": {"at": {"object": 0, "spot": "front"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/seam/enforcers": {"gt": 0}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/seam": {"exists": false}}},
{"tool": "action_run", "args": {"id": "orca_command:redo:orca"}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/seam.png", "overwrite": true, "include_image": false}},
{"tool": "widget_click", "args": {"target": {"imgui": "Done"}}},
// ---- Fuzzy skin: with it off for the object, the "enable painted fuzzy skin" link; then a Fill on the left face ----
{"tool": "settings_set", "args": {"target": "object", "object": 0, "values": {"fuzzy_skin": "disabled_fuzzy"}}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Fuzzy Skin Painting"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "Enable painted fuzzy skin"}}},
{"tool": "settings_get", "args": {"target": "object", "object": 0, "keys": ["fuzzy_skin"]}, "expect": {"/items/0/value": {"eq": "none"}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "Fill"}}},
{"tool": "mouse_gesture", "args": {"at": {"object": 0, "spot": "left"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/fuzzy_skin": {"gt": 0}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "action_run", "args": {"id": "orca_command:redo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/fuzzy_skin": {"gt": 0}}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/fuzzy_skin.png", "overwrite": true, "include_image": false}},
{"tool": "widget_click", "args": {"target": {"imgui": "Done"}}},
// ---- Color painting: filament 2 filled on the front; the painted volume's scene entry is inactive ----
{"tool": "widget_click", "args": {"target": {"gizmo": "Color Painting"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "extruder_color_2"}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "Fill"}}},
{"tool": "mouse_gesture", "args": {"at": {"object": 0, "spot": "front"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/mmu/2": {"gt": 0}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "action_run", "args": {"id": "orca_command:redo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/mmu/2": {"gt": 0}}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/color.png", "overwrite": true, "include_image": false}},
{"tool": "widget_click", "args": {"target": {"imgui": "Done"}}},
// ---- Texture displacement: import a height map, paint the top, a second layer added and removed ----
{"tool": "widget_click", "args": {"target": {"gizmo": "Texture Displacement"}}, "expect": {"/active": {"eq": true}}},
{"tool": "gizmo_pick_file", "args": {"action": "texture_import", "path": "${vars.heightmap}"}},
{"tool": "mouse_gesture", "args": {"action": "drag", "at": {"object": 0, "spot": "top"}, "waypoints": [{"object": 0, "point": [8, 0, 12.8]}], "to": {"object": 0, "point": [8, 8, 12.8]}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/texture/0/name": {"contains": "heightmap"}, "/plates/0/objects/0/parts/0/painted/texture/0/painted": {"gt": 0}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "add_layer"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/texture/1": {"exists": true}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "Remove", "index": 1}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/texture/1": {"exists": false}}},
// The remaining layer's card, collapsed when the second one was added, opens on its row; its
// "more settings" link is scrolled into view when the panel is too short to show it.
{"tool": "widget_click", "args": {"target": {"imgui_name": "Layer 1"}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "more"}}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/texture.png", "overwrite": true, "include_image": false}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "close"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
// ---- Text: the icon on a selected cube creates a text part; multiline text and a style ----
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Text"}}, "expect": {"/created": {"eq": true}, "/active": {"eq": true}}},
{"tool": "widget_set_value", "args": {"target": {"imgui_name": "Text"}, "value": ""}, "expect": {"/value": {"eq": ""}}},
{"tool": "widget_set_value", "args": {"target": {"imgui_name": "Text"}, "value": "Orca\nMCP"}, "expect": {"/value": {"eq": "Orca\nMCP"}}},
{"tool": "widget_set_value", "args": {"target": {"imgui": "Style"}, "value": "ITALIC"}, "expect": {"/selected": {"eq": "ITALIC"}}},
// A font Orca ships, so every system lists it; the font button's label, and so its id, changes
// with the font. It may lack some letters of the text, so it is reverted at once.
{"tool": "widget_set_value", "args": {"target": {"imgui_name": "Combo_Font"}, "value": "HarmonyOS Sans SC"}, "expect": {"/selected": {"eq": "HarmonyOS Sans SC"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "Revert font"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
// The second property's revert button resets that property.
{"tool": "widget_set_value", "args": {"target": {"imgui": "Depth"}, "value": 2.5}, "expect": {"/value": {"eq": "2.50 mm"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "Revert Depth"}}},
{"tool": "widget_list", "args": {"query": "2.50 mm"}, "expect": {"/nodes": {"eq": 0}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/1/text/text": {"eq": "Orca\nMCP"}, "/plates/0/objects/0/parts/1/text/style": {"eq": "ITALIC"}}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/text.png", "overwrite": true, "include_image": false}},
{"tool": "widget_click", "args": {"target": {"imgui": "Done"}}},
// ---- SVG: a new object with nothing selected, a part of the selected cube, then Change file and Save as ----
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_add_svg", "args": {"path": "${vars.svg}"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_list", "expect": {"/total": {"eq": 3}, "/plates/0/objects/2/parts/0/svg/path": {"contains": "star.svg"}}},
{"tool": "app_state", "expect": {"/gizmo/name": {"eq": "SVG"}}},
{"tool": "gizmo_pick_file", "args": {"action": "svg_save_as", "path": "${out_dir}/star-copy.svg", "overwrite": true}},
{"tool": "object_list", "expect": {"/plates/0/objects/2/parts/0/svg/path": {"contains": "star-copy.svg"}}},
{"tool": "gizmo_pick_file", "args": {"action": "svg_change", "path": "${vars.svg}"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_list", "expect": {"/plates/0/objects/2/parts/0/svg/path": {"contains": "star.svg"}}},
// The panel shows the new file's name.
{"tool": "widget_list", "args": {"query": "star-copy"}, "expect": {"/nodes": {"eq": 0}}},
{"tool": "widget_click", "args": {"target": {"gizmo": "SVG"}}},
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "object_add_svg", "args": {"path": "${vars.svg}"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/2/svg/path": {"contains": "star.svg"}}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/svg.png", "overwrite": true, "include_image": false}},
{"tool": "widget_click", "args": {"target": {"gizmo": "SVG"}}},
// ---- Measure: two faces at 90 degrees; then a Shift-clicked point in place of the second, a distance ----
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Measure"}}, "expect": {"/active": {"eq": true}}},
{"tool": "mouse_gesture", "args": {"action": "move", "at": {"object": 0, "spot": "front"}}},
{"tool": "mouse_gesture", "args": {"at": {"object": 0, "spot": "front"}}},
{"tool": "mouse_gesture", "args": {"at": {"object": 0, "spot": "left"}}},
{"tool": "widget_list", "args": {"query": "90.000"}, "expect": {"/nodes": {"gt": 0}}},
{"tool": "mouse_gesture", "args": {"modifiers": ["shift"], "at": {"object": 0, "point": [-12.8, 0, -8]}}},
{"tool": "widget_list", "args": {"query": "Point on plane"}, "expect": {"/nodes": {"gt": 0}}},
{"tool": "widget_list", "args": {"query": "Distance"}, "expect": {"/nodes": {"gt": 0}}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/measure.png", "overwrite": true, "include_image": false}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Measure"}}},
// ---- Simplify: the text part cut by 90 %; its count depends on the system font, so the bound is loose ----
{"tool": "object_select", "args": {"parts": [[0, 1]]}},
// Closed while it calculates, it leaves nothing to wait for.
{"tool": "widget_click", "args": {"target": {"gizmo": "Simplify"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_set_value", "args": {"target": {"imgui_name": "use_count"}, "value": true}},
{"tool": "widget_set_value", "args": {"target": {"imgui": "Decimate ratio"}, "value": 60}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Simplify"}}, "expect": {"/active": {"eq": false}}},
{"tool": "app_wait", "args": {"for": "idle", "timeout_s": 15}, "expect": {"/satisfied": {"eq": true}}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Simplify"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_set_value", "args": {"target": {"imgui_name": "use_count"}, "value": true}},
{"tool": "widget_set_value", "args": {"target": {"imgui": "Decimate ratio"}, "value": 90}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "widget_click", "args": {"target": {"imgui": "Apply"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/1/triangles": {"lt": 1000}}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/simplify.png", "overwrite": true, "include_image": false}},
// ---- Brim ears: the "set to painted" link, auto-generated ears and one more by a click ----
{"tool": "object_select", "args": {"objects": [1]}},
{"tool": "view_set", "args": {"camera": "iso"}},
{"tool": "view_set", "args": {"camera": "fit_selection"}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Brim Ears"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "Set brim type to painted"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/1/overrides": {"contains": "brim_type"}}},
{"tool": "widget_click", "args": {"target": {"imgui": "Auto-generate"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/1/brim_ears": {"gt": 0}}},
{"tool": "mouse_gesture", "args": {"at": {"object": 1, "point": [172.8, 100, 0.5], "frame": "world"}, "check": "point"}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/brim_ears.png", "overwrite": true, "include_image": false}},
{"tool": "widget_click", "args": {"target": {"imgui": "Done"}}},
// ---- Mesh boolean: the cube and its SVG part united into one part ----
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "view_set", "args": {"camera": "fit_selection"}},
{"tool": "widget_click", "args": {"target": {"gizmo": "MeshBoolean"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_click", "args": {"target": {"imgui": "Union", "index": 0}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "select_source_volume"}}},
{"tool": "mouse_gesture", "args": {"at": {"object": 0, "part": 0, "spot": "front"}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "select_tool_volume"}}},
{"tool": "mouse_gesture", "args": {"at": {"object": 0, "part": 2, "spot": "top"}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "btn"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/2": {"exists": false}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/2": {"exists": true}}},
{"tool": "action_run", "args": {"id": "orca_command:redo:orca"}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/mesh_boolean.png", "overwrite": true, "include_image": false}},
{"tool": "widget_click", "args": {"target": {"gizmo": "MeshBoolean"}}},
// ---- Assembly, in the assemble view: a face of each object picked, then mated at a distance ----
// The assemble view shows the objects selected when it opens, where they sit in the assembly. Both
// cubes were made at the same spot, so its Move gizmo first moves object 1 apart there.
{"tool": "object_select", "args": {"objects": [0, 1]}},
{"tool": "view_set", "args": {"canvas": "assemble"}},
{"tool": "view_set", "args": {"camera": "iso"}},
{"tool": "object_select", "args": {"objects": [1]}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Move", "canvas": "assemble"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_set_value", "args": {"target": {"imgui": "Position", "canvas": "assemble"}, "value": 60}, "expect": {"/value": {"eq": "60.00"}}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Move", "canvas": "assemble"}}, "expect": {"/active": {"eq": false}}},
{"tool": "view_set", "args": {"camera": "fit_objects"}},
{"tool": "object_select", "args": {"all": true}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Assembly", "canvas": "assemble"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_set_value", "args": {"target": {"imgui": "Mode"}, "value": "Face and face assembly"}},
{"tool": "mouse_gesture", "args": {"canvas": "assemble", "action": "move", "at": {"object": 0, "spot": "left"}}},
{"tool": "mouse_gesture", "args": {"canvas": "assemble", "at": {"object": 0, "spot": "left"}}},
{"tool": "mouse_gesture", "args": {"canvas": "assemble", "action": "move", "at": {"object": 1, "spot": "left"}}},
{"tool": "mouse_gesture", "args": {"canvas": "assemble", "at": {"object": 1, "spot": "left"}}},
{"tool": "widget_set_value", "args": {"target": {"imgui_name": "parallel_distance_z"}, "value": 0}, "expect": {"/value": {"eq": "0.00"}}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/assembly.png", "overwrite": true, "include_image": false}},
{"tool": "widget_click", "args": {"target": {"imgui": "Return"}}},
{"tool": "app_state", "expect": {"/gizmo": {"eq": null}}},
// ---- Cut: a connector on the plane, Frustum and Square in their combos, then the cut ----
{"tool": "view_set", "args": {"camera": "iso"}},
{"tool": "object_select", "args": {"objects": [1]}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Cut"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_set_value", "args": {"target": {"imgui_name": "move_Z"}, "value": 10}, "expect": {"/value": {"eq": "10.00"}}},
{"tool": "widget_click", "args": {"target": {"imgui": "Add connectors"}}},
{"tool": "widget_set_value", "args": {"target": {"imgui": "Style"}, "value": "Frustum"}, "expect": {"/selected": {"eq": "Frustum"}}},
{"tool": "widget_set_value", "args": {"target": {"imgui": "Shape"}, "value": "Square"}, "expect": {"/selected": {"eq": "Square"}}},
{"tool": "widget_click", "args": {"target": {"imgui": "Confirm connectors"}}},
{"tool": "widget_click", "args": {"target": {"imgui": "Perform cut"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_list", "expect": {"/total": {"eq": 4}}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/cut.png", "overwrite": true, "include_image": false}}
]
}
-240
View File
@@ -1,240 +0,0 @@
// Layer-based edits: height range modifiers set with object_set_height_ranges and their settings with settings_set
// (target height_range), and variable layer height profiles set with object_set_variable_layer_height, read back
// through object_list, each change undone in one step,
// sliced, and kept by a 3MF; and a plate's layer G-codes set with plate_set_custom_gcode, read back from its
// replies, edited, sliced, and kept by a 3MF. Run on a live app:
// python3 tools/mcp/orca_mcp.py run-replay tools/mcp/tests/layers.json --out <dir>
// A refusal can't be asserted directly (a failed step stops the run), so each one is an optional
// step followed by a check that nothing changed.
{
"orca_replay_version": "0.2.0",
"name": "layer-based edits",
"vars": {"cube": "${replay_dir}/../../../resources/handy_models/OrcaCube_v2.drc",
"benchy": "${replay_dir}/../../../resources/handy_models/3DBenchy.drc"},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "window_set", "args": {"size": [1600, 900]}},
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "project_import", "args": {"paths": ["${vars.cube}"]}, "expect": {"/added": {"eq": 1}}},
{"tool": "object_transform", "args": {"object": 0, "size": [20, 20, 20]}},
{"tool": "settings_set", "args": {"type": "process", "values": {"layer_height": 0.2, "initial_layer_print_height": 0.2}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_config_ranges": {"exists": false}}},
// ---- Two ranges, given in any order, at the object's layer height and filament; then the lower half at 40 %
// infill, the upper half at 0.1 mm ----
{"tool": "object_set_height_ranges",
"args": {"object": 0, "ranges": [{"min_z": 10, "max_z": 20}, {"min_z": 0, "max_z": 10}]},
"expect": {"/height": {"ge": 19.99, "le": 20.01},
"/layer_config_ranges/0/max_z": {"eq": 10},
"/layer_config_ranges/0/values/layer_height": {"eq": "0.2"},
"/layer_config_ranges/1/min_z": {"eq": 10},
"/layer_config_ranges/1/values/layer_height": {"eq": "0.2"},
"/layer_config_ranges/1/values/extruder": {"eq": "0"},
"/warnings": {"exists": false}}},
{"tool": "settings_set", "args": {"target": "height_range", "object": 0, "min_z": 0, "max_z": 10,
"values": {"sparse_infill_density": "40%"}},
"expect": {"/applied/sparse_infill_density": {"eq": "40%"}, "/height_range/max_z": {"eq": 10}}},
{"tool": "settings_set", "args": {"target": "height_range", "object": 0, "min_z": 10, "max_z": 20, "values": {"layer_height": 0.1}},
"expect": {"/applied/layer_height": {"eq": "0.1"}, "/height_range/min_z": {"eq": 10}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_config_ranges/0/values/sparse_infill_density": {"eq": "40%"},
"/plates/0/objects/0/layer_config_ranges/1/values/layer_height": {"eq": "0.1"},
"/plates/0/objects/0/layer_config_ranges/2": {"exists": false}}},
// Ranges are not the object's own overrides.
{"tool": "settings_get", "args": {"target": "object", "object": 0, "keys": ["sparse_infill_density"], "include_meta": false},
"expect": {"/items/0/value": {"eq": null}}},
// ---- Each change one undo step; the same ranges again keep their settings and add none ----
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_config_ranges/1/values/layer_height": {"eq": "0.2"},
"/plates/0/objects/0/layer_config_ranges/0/values/sparse_infill_density": {"eq": "40%"}}},
{"tool": "action_run", "args": {"id": "orca_command:redo:orca"}},
{"tool": "object_set_height_ranges",
"args": {"object": 0, "ranges": [{"min_z": 0, "max_z": 10}, {"min_z": 10, "max_z": 20}]},
"expect": {"/layer_config_ranges/0/values/sparse_infill_density": {"eq": "40%"},
"/layer_config_ranges/1/values/layer_height": {"eq": "0.1"}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_config_ranges/1/values/layer_height": {"eq": "0.2"}}},
{"tool": "action_run", "args": {"id": "orca_command:redo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_config_ranges/1/values/layer_height": {"eq": "0.1"}}},
// ---- The slicer prints them: 50 layers of 0.2 mm, then 100 of 0.1 mm ----
{"tool": "plate_slice", "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
{"tool": "view_set", "args": {"tab": "preview", "layer": 1}, "expect": {"/layers/2": {"ge": 149, "le": 151}}},
// ---- Refusals change nothing: an overlap, a layer height beyond the printer's, a filament the
// project lacks, an object setting, an empty range ----
{"tool": "object_set_height_ranges", "args": {"object": 0, "ranges": [{"min_z": 0, "max_z": 15}, {"min_z": 12, "max_z": 20}]},
"optional": true},
{"tool": "settings_set", "args": {"target": "height_range", "object": 0, "min_z": 0, "max_z": 10, "values": {"layer_height": 0.5}},
"optional": true},
{"tool": "settings_set", "args": {"target": "height_range", "object": 0, "min_z": 0, "max_z": 10, "values": {"extruder": 9}},
"optional": true},
{"tool": "settings_set", "args": {"target": "height_range", "object": 0, "min_z": 0, "max_z": 10, "values": {"enable_support": true}},
"optional": true},
{"tool": "object_set_height_ranges", "args": {"object": 0, "ranges": [{"min_z": 5, "max_z": 5}]}, "optional": true},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_config_ranges/0/max_z": {"eq": 10},
"/plates/0/objects/0/layer_config_ranges/0/values/layer_height": {"eq": "0.2"},
"/plates/0/objects/0/layer_config_ranges/0/values/extruder": {"eq": "0"},
"/plates/0/objects/0/layer_config_ranges/0/values/enable_support": {"exists": false},
"/plates/0/objects/0/layer_config_ranges/1/values/layer_height": {"eq": "0.1"},
"/plates/0/objects/0/layer_config_ranges/2": {"exists": false}}},
// ---- A range printed with the second filament, above the object's top ----
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "widget_click", "args": {"target": {"label": "Add one filament"}}},
{"tool": "object_set_height_ranges",
"args": {"object": 0, "ranges": [{"min_z": 0, "max_z": 10}, {"min_z": 10, "max_z": 20}, {"min_z": 20, "max_z": 30}]},
"expect": {"/height": {"le": 20.01}, "/layer_config_ranges/0/values/sparse_infill_density": {"eq": "40%"},
"/layer_config_ranges/2/values/extruder": {"eq": "0"}}},
{"tool": "settings_set", "args": {"target": "height_range", "object": 0, "min_z": 20, "max_z": 30, "values": {"extruder": 2}},
"expect": {"/applied/extruder": {"eq": "2"}}},
// ---- A 3MF keeps them ----
{"tool": "project_save", "args": {"path": "${out_dir}/layers.3mf", "overwrite": true}},
{"tool": "project_new", "args": {"discard_changes": true}},
// Loading a project asks about preset edits an earlier replay left; the project brings its own.
{"tool": "dialog_auto_answer", "args": {"rules": [{"match": "unsaved changes", "button": "Discard"}]}},
{"tool": "project_open", "args": {"path": "${out_dir}/layers.3mf", "discard_changes": true}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_config_ranges/0/values/sparse_infill_density": {"eq": "40%"},
"/plates/0/objects/0/layer_config_ranges/1/values/layer_height": {"eq": "0.1"},
"/plates/0/objects/0/layer_config_ranges/2/values/extruder": {"eq": "2"}}},
// ---- [] removes them all ----
{"tool": "object_set_height_ranges", "args": {"object": 0, "ranges": []}, "expect": {"/layer_config_ranges": {"eq": []}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_config_ranges": {"exists": false}}},
{"tool": "plate_slice", "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
{"tool": "view_set", "args": {"tab": "preview", "layer": 1}, "expect": {"/layers/2": {"eq": 100}}},
// ---- Variable layer height on a Benchy (48 mm; 240 layers at 0.2 mm), called from the Preview tab ----
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "project_import", "args": {"paths": ["${vars.benchy}"]}, "expect": {"/added": {"eq": 1}}},
{"tool": "settings_set", "args": {"type": "process", "values": {"layer_height": 0.2, "initial_layer_print_height": 0.2}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_height_profile": {"exists": false}}},
{"tool": "plate_slice", "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
{"tool": "object_set_variable_layer_height", "args": {"object": 0, "action": "adaptive"},
"expect": {"/height": {"ge": 47.99, "le": 48.01},
"/layer_height_profile/points": {"gt": 250},
"/layer_height_profile/min_height": {"lt": 0.2},
"/layer_height_profile/max_height": {"gt": 0.2},
"/warnings": {"exists": false}}},
{"tool": "app_state", "expect": {"/tab": {"eq": "prepare"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_height_profile/points": {"gt": 250}}},
// Toward quality more layers, toward speed fewer.
{"tool": "object_set_variable_layer_height", "args": {"object": 0, "action": "adaptive", "quality": 0},
"expect": {"/layer_height_profile/points": {"gt": 380}}},
{"tool": "object_set_variable_layer_height", "args": {"object": 0, "action": "adaptive", "quality": 1},
"expect": {"/layer_height_profile/points": {"lt": 320}}},
// The slicer prints the profile, not 240 layers of 0.2 mm.
{"tool": "plate_slice", "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
{"tool": "view_set", "args": {"tab": "preview", "layer": 1}, "expect": {"/layers/2": {"gt": 245}}},
// ---- Smooth is one undo step; Reset removes the profile, and again changes nothing ----
{"tool": "object_set_variable_layer_height", "args": {"object": 0, "action": "smooth", "radius": 10, "keep_min": true},
"expect": {"/layer_height_profile/max_height": {"lt": 0.28}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_height_profile/max_height": {"eq": 0.28}}},
{"tool": "action_run", "args": {"id": "orca_command:redo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_height_profile/max_height": {"lt": 0.28}}},
{"tool": "object_set_variable_layer_height", "args": {"object": 0, "action": "reset"}, "expect": {"/layer_height_profile": {"exists": false}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_height_profile": {"exists": false}}},
{"tool": "object_set_variable_layer_height", "args": {"object": 0, "action": "reset"}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_height_profile/max_height": {"lt": 0.28}}},
{"tool": "object_set_variable_layer_height", "args": {"object": 0, "action": "reset"}},
// ---- Refusals change nothing: an argument of another action, the assemble view ----
{"tool": "object_set_variable_layer_height", "args": {"object": 0, "action": "smooth", "quality": 0.3}, "optional": true},
{"tool": "view_set", "args": {"canvas": "assemble"}},
{"tool": "object_set_variable_layer_height", "args": {"object": 0, "action": "adaptive"}, "optional": true},
{"tool": "view_set", "args": {"canvas": "3d"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_height_profile": {"exists": false}}},
// ---- With height ranges: Smooth starts from the ranges' heights, Adaptive keeps them inside each
// range, and the profile then decides ----
{"tool": "object_set_height_ranges",
"args": {"object": 0, "ranges": [{"min_z": 0, "max_z": 20}, {"min_z": 20, "max_z": 48}]}},
{"tool": "settings_set", "args": {"target": "height_range", "object": 0, "min_z": 0, "max_z": 20, "values": {"layer_height": 0.12}}},
{"tool": "settings_set", "args": {"target": "height_range", "object": 0, "min_z": 20, "max_z": 48, "values": {"layer_height": 0.28}}},
{"tool": "object_set_variable_layer_height", "args": {"object": 0, "action": "smooth"},
"expect": {"/layer_height_profile/min_height": {"eq": 0.12},
"/layer_height_profile/max_height": {"eq": 0.28},
"/warnings/0": {"contains": "decides its layer heights"}}},
{"tool": "object_set_variable_layer_height", "args": {"object": 0, "action": "adaptive", "quality": 0},
"expect": {"/layer_height_profile/min_height": {"eq": 0.12}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_config_ranges/1/values/layer_height": {"eq": "0.28"},
"/plates/0/objects/0/layer_height_profile/min_height": {"eq": 0.12}}},
// ---- A 3MF keeps the profile ----
{"tool": "project_save", "args": {"path": "${out_dir}/profile.3mf", "overwrite": true}},
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "project_open", "args": {"path": "${out_dir}/profile.3mf", "discard_changes": true}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/layer_height_profile/min_height": {"eq": 0.12},
"/plates/0/objects/0/layer_height_profile/points": {"gt": 100}}},
{"tool": "plate_slice", "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
// ---- Layer G-codes on a 20 mm cube of 100 layers of 0.2 mm: none before a slice ----
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "project_import", "args": {"paths": ["${vars.cube}"]}, "expect": {"/added": {"eq": 1}}},
{"tool": "object_transform", "args": {"object": 0, "size": [20, 20, 20]}},
{"tool": "settings_set", "args": {"type": "process", "values": {"layer_height": 0.2, "initial_layer_print_height": 0.2}}},
{"tool": "plate_set_custom_gcode", "args": {"add": [{"layer": 26, "type": "pause"}]}, "optional": true},
{"tool": "app_state", "expect": {"/tab": {"eq": "prepare"}, "/slicing": {"eq": false}}},
{"tool": "plate_slice", "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
// ---- From Prepare: a pause by layer and custom G-code by a height between layers, which goes on
// the layer whose top is above it; the call shows the Preview ----
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "plate_set_custom_gcode", "args": {"add": [{"layer": 26, "type": "pause"}, {"z": 10.1, "type": "custom", "gcode": "M104 S215"}]},
"expect": {"/plate": {"eq": 0}, "/layers": {"eq": 100}, "/changed": {"eq": true},
"/layer_gcode/0/type": {"eq": "pause"}, "/layer_gcode/0/layer": {"eq": 26}, "/layer_gcode/0/z": {"eq": 5.2},
"/layer_gcode/1/type": {"eq": "custom"}, "/layer_gcode/1/layer": {"eq": 51}, "/layer_gcode/1/z": {"eq": 10.2},
"/layer_gcode/1/gcode": {"eq": "M104 S215"}, "/layer_gcode/2": {"exists": false},
"/note": {"contains": "slice it again"}}},
{"tool": "app_state", "expect": {"/tab": {"eq": "preview"}, "/project/dirty": {"eq": true}}},
// ---- The plate stays editable while the Preview shows it: the same codes change nothing, and in one
// call the pause goes (by its height) and the custom text is replaced ----
{"tool": "plate_set_custom_gcode", "args": {"add": [{"z": 5.2, "type": "pause"}]},
"expect": {"/changed": {"eq": false}, "/layer_gcode/0/layer": {"eq": 26}, "/layer_gcode/1/layer": {"eq": 51}}},
{"tool": "plate_set_custom_gcode", "args": {"remove": [{"z": 5.2}], "add": [{"layer": 51, "type": "custom", "gcode": "M104 S220"}]},
"expect": {"/changed": {"eq": true}, "/layer_gcode/0/layer": {"eq": 51}, "/layer_gcode/0/gcode": {"eq": "M104 S220"},
"/layer_gcode/1": {"exists": false}}},
// ---- Refusals change nothing: a layer above the top, another code where one is, nothing to remove,
// a filament the project lacks (it has the two the height ranges above used), a plate it lacks ----
{"tool": "plate_set_custom_gcode", "args": {"add": [{"layer": 101, "type": "pause"}]}, "optional": true},
{"tool": "plate_set_custom_gcode", "args": {"add": [{"layer": 51, "type": "pause"}]}, "optional": true},
{"tool": "plate_set_custom_gcode", "args": {"remove": [{"layer": 30}]}, "optional": true},
{"tool": "plate_set_custom_gcode", "args": {"add": [{"layer": 30, "type": "change_filament", "filament": 9}]}, "optional": true},
{"tool": "plate_set_custom_gcode", "args": {"plate": 1, "add": [{"layer": 30, "type": "pause"}]}, "optional": true},
{"tool": "plate_set_custom_gcode", "args": {"add": [{"layer": 51, "type": "custom", "gcode": "M104 S220"}]},
"expect": {"/changed": {"eq": false}, "/layer_gcode/0/gcode": {"eq": "M104 S220"}, "/layer_gcode/1": {"exists": false}}},
// ---- Changed since its slice and not shown: refused without starting a slice ----
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "plate_set_custom_gcode", "args": {"add": [{"layer": 30, "type": "pause"}]}, "optional": true},
{"tool": "app_state", "expect": {"/tab": {"eq": "prepare"}, "/slicing": {"eq": false}}},
// ---- A filament change to the second filament ----
{"tool": "plate_slice", "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
{"tool": "plate_set_custom_gcode", "args": {"add": [{"layer": 76, "type": "change_filament", "filament": 2}]},
"expect": {"/layer_gcode/0/layer": {"eq": 51}, "/layer_gcode/1/layer": {"eq": 76}, "/layer_gcode/1/z": {"eq": 15.2},
"/layer_gcode/1/type": {"eq": "change_filament"}, "/layer_gcode/1/filament": {"eq": 2},
"/layer_gcode/1/color": {"exists": true}}},
{"tool": "plate_slice", "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
// ---- A 3MF keeps them ----
{"tool": "project_save", "args": {"path": "${out_dir}/layer_gcode.3mf", "overwrite": true}},
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "project_open", "args": {"path": "${out_dir}/layer_gcode.3mf", "discard_changes": true}},
{"tool": "plate_slice", "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
{"tool": "plate_set_custom_gcode", "args": {"add": [{"layer": 76, "type": "change_filament", "filament": 2}]},
"expect": {"/changed": {"eq": false}, "/layer_gcode/0/gcode": {"eq": "M104 S220"},
"/layer_gcode/1/filament": {"eq": 2}, "/layer_gcode/2": {"exists": false}}},
// ---- clear removes them all ----
{"tool": "plate_set_custom_gcode", "args": {"clear": true}, "expect": {"/changed": {"eq": true}, "/layer_gcode": {"eq": []}}},
{"tool": "plate_slice", "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}}
]
}
-61
View File
@@ -1,61 +0,0 @@
// The object commands made from menu items, called by index, and with no target on the selection: object_rename,
// object_set_instances, object_separate_instances and object_delete name what they act on in their replies, which
// object_list reads back; the Delete Selected action deletes the selection; object_set_height_ranges and
// object_set_variable_layer_height without object act on the selected object and name it. Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/menu_items_objects.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "object menu items by index",
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_list", "expect": {"/total": {"eq": 3}}},
// ---- By index: rename the second, give the first three instances and make one of them an object ----
{"tool": "object_rename", "args": {"object": 1, "name": "middle"},
"expect": {"/objects/0/index": {"eq": 1}, "/objects/0/name": {"eq": "middle"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/1/name": {"eq": "middle"}, "/plates/0/objects/0/name": {"ne": "middle"}}},
{"tool": "object_set_instances", "args": {"object": 0, "count": 3},
"expect": {"/object": {"eq": 0}, "/instances": {"eq": 3}, "/objects/0/index": {"eq": 0}}},
{"tool": "object_separate_instances", "args": {"instances": [[0, 2]]},
"expect": {"/objects/0/index": {"eq": 3}, "/objects/1": {"exists": false}}},
{"tool": "object_list", "expect": {"/total": {"eq": 4}, "/plates/0/objects/0/instances/1": {"exists": true},
"/plates/0/objects/0/instances/2": {"exists": false},
"/plates/0/objects/3/instances/0": {"exists": true}}},
// ---- Delete by index, then the selection, by the command and by its Delete Selected action ----
{"tool": "object_delete", "args": {"objects": [0]}, "expect": {"/objects/0/index": {"eq": 0}, "/object_count": {"eq": 3}}},
{"tool": "object_list", "expect": {"/total": {"eq": 3}, "/plates/0/objects/0/name": {"eq": "middle"}}},
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "object_delete", "args": {}, "expect": {"/objects/0/index": {"eq": 0}, "/objects/0/name": {"eq": "middle"},
"/object_count": {"eq": 2}}},
{"tool": "object_list", "expect": {"/total": {"eq": 2}, "/plates/0/objects/0/name": {"ne": "middle"}}},
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "action_run", "args": {"id": "orca_command:obj_delete:orca"},
"expect": {"/objects/0/index": {"eq": 0}, "/object_count": {"eq": 1}}},
{"tool": "object_list", "expect": {"/total": {"eq": 1}}},
// ---- With no object, the layer commands act on the selected one and name it ----
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "object_rename", "args": {"object": 1, "name": "layered"}},
{"tool": "object_select", "args": {"objects": [1]}},
{"tool": "object_set_height_ranges", "args": {"ranges": [{"min_z": 0, "max_z": 5}]},
"expect": {"/object": {"eq": 1}, "/objects/0/index": {"eq": 1}, "/objects/0/name": {"eq": "layered"},
"/layer_config_ranges/0/max_z": {"eq": 5}}},
{"tool": "object_list", "expect": {"/plates/0/objects/1/layer_config_ranges/0/max_z": {"eq": 5},
"/plates/0/objects/0/layer_config_ranges": {"exists": false}}},
{"tool": "object_set_variable_layer_height", "args": {"action": "adaptive"},
"expect": {"/object": {"eq": 1}, "/objects/0/index": {"eq": 1}, "/objects/0/name": {"eq": "layered"},
"/layer_height_profile": {"exists": true}}},
{"tool": "project_new", "args": {"discard_changes": true}}
]
}
-107
View File
@@ -1,107 +0,0 @@
// The placement commands made from menu items, called by index: object_add_primitive on a plate, at a position and with a
// name while another object is selected, in one undo step (the snapshots read from the log, fixtures/ops_undo.py);
// object_mirror, object_drop, object_center (each plate's objects on their own plate, then all on one),
// object_scale_to_fit and object_auto_orient (a cube on its edge laid on a face), each read back through object_list;
// and the Center, Drop, Scale to Fit and Auto-Orient actions on the selection. Plate positions are those of the sweep's
// printer, a Bambu Lab X1 Carbon (a 256 mm bed): with three plates, plate 1's centre is at x 435.2, y 128 and plate 2's
// at x 128, y -179.2. Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/menu_items_placement.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "placement menu items by index",
"vars": {"undo": "${replay_dir}/fixtures/ops_undo.py"},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "plate_add", "args": {}},
{"tool": "plate_add", "args": {}},
{"tool": "plate_select", "args": {"plate": 1}},
// ---- A cube added on plate 1, then a second at a position on plate 1 while the first is selected ----
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20], "plate": 1, "name": "first"},
"expect": {"/object": {"eq": 0}, "/plate": {"eq": 1}, "/objects/0/name": {"eq": "first"}}},
{"tool": "app_state", "expect": {"/selection/objects": {"eq": [0]}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20], "position": [420, 110, 0], "name": "second"},
"expect": {"/object": {"eq": 1}, "/plate": {"eq": 1}, "/offset/0": {"ge": 419.99, "le": 420.01}, "/offset/1": {"ge": 109.99, "le": 110.01}}},
// added, named and placed in one undo step
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"},
"expect": {"/result/count": {"eq": 1}, "/result/taken/0": {"eq": "Add Primitive"}}},
{"tool": "object_list", "expect": {"/total": {"eq": 2}, "/plates/1/objects/0/name": {"eq": "first"}, "/plates/1/objects/1/name": {"eq": "second"},
"/plates/1/objects/1/bbox/min/2": {"ge": -0.001, "le": 0.001}}},
// ---- Mirror by index ----
{"tool": "object_mirror", "args": {"objects": [0], "axis": "x"}, "expect": {"/objects/0/index": {"eq": 0}}},
{"tool": "object_list", "expect": {"/plates/1/objects/0/instances/0/mirrored": {"eq": true},
"/plates/1/objects/1/instances/0/mirrored": {"eq": false}}},
// ---- Drop by index: an object of two parts stays above the bed where it is moved without a drop ----
{"tool": "part_add", "args": {"object": 1, "type": "part", "shape": "cube", "size": [5, 5, 5]}},
{"tool": "object_transform", "args": {"object": 1, "translate": [0, 0, 15], "drop_to_bed": false}},
{"tool": "object_list", "expect": {"/plates/1/objects/1/bbox/min/2": {"ge": 10}}},
{"tool": "object_drop", "args": {"objects": [1]}, "expect": {"/moved": {"eq": true}, "/objects/0/index": {"eq": 1}}},
{"tool": "object_list", "expect": {"/plates/1/objects/1/bbox/min/2": {"ge": -0.001, "le": 0.001}}},
{"tool": "object_drop", "args": {"objects": [1]}, "expect": {"/moved": {"eq": false}}},
// the Drop to Bed action on the selection
{"tool": "object_transform", "args": {"object": 1, "translate": [0, 0, 15], "drop_to_bed": false}},
{"tool": "object_select", "args": {"objects": [1]}},
{"tool": "action_run", "args": {"id": "orca_command:obj_drop:orca"}, "expect": {"/moved": {"eq": true}}},
{"tool": "object_list", "expect": {"/plates/1/objects/1/bbox/min/2": {"ge": -0.001, "le": 0.001}}},
// ---- Centre by index on its plate ----
{"tool": "object_center", "args": {"objects": [0]}, "expect": {"/plates/0/plate": {"eq": 1}, "/plates/1": {"exists": false}}},
{"tool": "object_list", "expect": {"/plates/1/objects/0/instances/0/offset/0": {"ge": 435.1, "le": 435.3},
"/plates/1/objects/0/instances/0/offset/1": {"ge": 127.9, "le": 128.1}}},
// ---- A third object on plate 2, off its centre; plate 1 stays current ----
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20], "position": [60, -120, 0], "name": "third"},
"expect": {"/object": {"eq": 2}, "/plate": {"eq": 2}}},
// each object centred on the plate it stands on: the third moves to plate 2's centre and stays there
{"tool": "object_center", "args": {"objects": [0, 2]},
"expect": {"/plates/0/plate": {"eq": 1}, "/plates/0/objects": {"eq": [0]}, "/plates/1/plate": {"eq": 2}, "/plates/1/objects": {"eq": [2]}}},
{"tool": "object_list", "expect": {"/plates/2/objects/0/name": {"eq": "third"},
"/plates/2/objects/0/instances/0/offset/0": {"ge": 127.9, "le": 128.1},
"/plates/2/objects/0/instances/0/offset/1": {"ge": -179.3, "le": -179.1},
"/plates/1/objects/0/instances/0/offset/0": {"ge": 435.1, "le": 435.3}}},
// a second call moves nothing
{"tool": "object_center", "args": {"objects": [0, 2]}},
{"tool": "object_list", "expect": {"/plates/2/objects/0/instances/0/offset/0": {"ge": 127.9, "le": 128.1},
"/plates/2/objects/0/instances/0/offset/1": {"ge": -179.3, "le": -179.1},
"/plates/1/objects/0/instances/0/offset/0": {"ge": 435.1, "le": 435.3}}},
// all three on plate 1, as one group, whose box goes to the plate's centre: the third first moves to the corner of
// plate 2 nearest plate 1, so that the group fits on one bed
{"tool": "object_transform", "args": {"object": 2, "position": [240, -66, 10]}},
{"tool": "object_list", "expect": {"/plates/2/objects/0/name": {"eq": "third"}}},
{"tool": "object_center", "args": {"objects": [0, 1, 2], "plate": 1}, "expect": {"/plates/0/plate": {"eq": 1}, "/plates/0/objects": {"eq": [0, 1, 2]}}},
{"tool": "object_list", "expect": {"/plates/1/objects/2/name": {"eq": "third"}, "/plates/2/objects/0": {"exists": false}, "/outside": {"empty": true}}},
// ---- The Center action on the one selected: the current plate's centre ----
{"tool": "object_transform", "args": {"object": 2, "translate": [30, 0, 0]}},
{"tool": "object_select", "args": {"objects": [2]}},
{"tool": "action_run", "args": {"id": "orca_command:obj_center:orca"}, "expect": {"/plates/0/plate": {"eq": 1}, "/objects/0/index": {"eq": 2}}},
{"tool": "object_list", "expect": {"/plates/1/objects/2/instances/0/offset/0": {"ge": 435.1, "le": 435.3},
"/plates/1/objects/2/instances/0/offset/1": {"ge": 127.9, "le": 128.1}}},
// ---- Scale to fit by index, and the action on the selection ----
{"tool": "object_scale_to_fit", "args": {"objects": [0]}, "expect": {"/scales/0/object": {"eq": 0}, "/scales/0/scale/0": {"gt": 5}}},
{"tool": "object_list", "expect": {"/plates/1/objects/0/instances/0/scale/0": {"gt": 5}}},
{"tool": "object_select", "args": {"objects": [2]}},
{"tool": "action_run", "args": {"id": "orca_command:obj_fit_volume:orca"}, "expect": {"/scales/0/object": {"eq": 2}, "/scales/0/scale/0": {"gt": 5}}},
// ---- Auto-orient two objects by index; the reply is read once the job has ended: the cube on its edge lies on a face ----
{"tool": "object_transform", "args": {"object": 2, "rotate": [45, 0, 0], "mode": "absolute"}},
{"tool": "object_auto_orient", "args": {"objects": [1, 2]},
"expect": {"/objects/0/index": {"eq": 1}, "/objects/1/index": {"eq": 2}, "/objects/2": {"exists": false},
"/rotations/0/object": {"eq": 1}, "/rotations/1/object": {"eq": 2},
"/rotations/1/rotation_deg/0": {"ge": 89.9, "le": 90.1}}},
{"tool": "object_list", "expect": {"/plates/1/objects/2/instances/0/rotation_deg/0": {"ge": 89.9, "le": 90.1}}},
{"tool": "app_state", "expect": {"/selection/objects": {"eq": [1, 2]}}},
// the Auto-Orient action with nothing selected orients every object
{"tool": "object_select", "args": {"none": true}},
{"tool": "app_state", "expect": {"/selection/empty": {"eq": true}}},
{"tool": "action_run", "args": {"id": "orca_command:obj_orient:orca"}, "expect": {"/rotations/2/object": {"eq": 2}, "/rotations/3": {"exists": false}}},
{"tool": "project_new", "args": {"discard_changes": true}}
]
}
-64
View File
@@ -1,64 +0,0 @@
// The object structure commands made from menu items, called by index: object_split into objects and into parts,
// object_assemble, part_change_type and object_order name what they made or renumbered in their replies, which
// object_list reads back; the Split to Objects action splits the selected object. Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/menu_items_structure.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "object structure menu items by index",
"vars": {"two_shells": "${replay_dir}/../../../tests/data/two_hollow_squares.obj"},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "view_set", "args": {"tab": "prepare"}},
// ---- A model of two shells, split into objects by index; both rest on the bed, so nothing is asked ----
{"tool": "project_import", "args": {"paths": ["${vars.two_shells}"]}, "expect": {"/added": {"eq": 1}}},
{"tool": "object_list", "expect": {"/total": {"eq": 1}, "/plates/0/objects/0/parts/1": {"exists": false}}},
{"tool": "object_split", "args": {"object": 0, "into": "objects"},
"expect": {"/objects/0/index": {"eq": 0}, "/objects/1/index": {"eq": 1}, "/objects/2": {"exists": false}, "/object_count": {"eq": 2}}},
{"tool": "object_list", "expect": {"/total": {"eq": 2}, "/plates/0/objects/1/parts/1": {"exists": false}}},
// ---- Another, split into parts by index: the part becomes one part per shell ----
{"tool": "project_import", "args": {"paths": ["${vars.two_shells}"]}, "expect": {"/added": {"eq": 1}}},
{"tool": "object_split", "args": {"object": 2, "into": "parts"},
"expect": {"/parts/0/object": {"eq": 2}, "/parts/0/part": {"eq": 0}, "/parts/1/part": {"eq": 1}, "/parts/2": {"exists": false},
"/object_count": {"eq": 3}}},
{"tool": "object_list", "expect": {"/total": {"eq": 3}, "/plates/0/objects/2/parts/1/type": {"eq": "part"},
"/plates/0/objects/2/parts/2": {"exists": false}}},
// ---- The first two assembled by index: they go, and the assembly is added last ----
{"tool": "object_assemble", "args": {"objects": [0, 1]},
"expect": {"/object": {"eq": 1}, "/name": {"eq": "Assembly"}, "/objects/0/index": {"eq": 1}, "/objects/0/name": {"eq": "Assembly"}}},
{"tool": "object_list", "expect": {"/total": {"eq": 2}, "/plates/0/objects/1/name": {"eq": "Assembly"},
"/plates/0/objects/1/parts/1": {"exists": true}, "/plates/0/objects/0/parts/1": {"exists": true}}},
// ---- Part 0 of object 0 made a modifier: parts are listed by type, so it moves after the solid part, to 1 ----
{"tool": "part_change_type", "args": {"parts": [[0, 0]], "type": "modifier"},
"expect": {"/parts/0/object": {"eq": 0}, "/parts/0/part": {"eq": 1}, "/parts/0/type": {"eq": "modifier"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/type": {"eq": "part"}, "/plates/0/objects/0/parts/1/type": {"eq": "modifier"}}},
// ---- The plate ordered by height, then descending; the order read back ----
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 30]}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 10]}},
{"tool": "object_order", "args": {"by": "height", "plate": 0},
"expect": {"/descending": {"eq": false}, "/order/3/plate": {"eq": 0}, "/order/4": {"exists": false}}},
{"tool": "object_list", "expect": {"/plates/0/objects/2/bbox/size/2": {"ge": 9.99, "le": 10.01},
"/plates/0/objects/3/bbox/size/2": {"ge": 29.99, "le": 30.01}}},
// the same call again keeps the order: only the action's call reverses it
{"tool": "object_order", "args": {"by": "height", "plate": 0}, "expect": {"/descending": {"eq": false}}},
{"tool": "object_order", "args": {"by": "height", "descending": true}, "expect": {"/descending": {"eq": true}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/bbox/size/2": {"ge": 29.99, "le": 30.01},
"/plates/0/objects/1/bbox/size/2": {"ge": 9.99, "le": 10.01}}},
// ---- The Split to Objects action on the selected object of two shells ----
{"tool": "project_import", "args": {"paths": ["${vars.two_shells}"]}, "expect": {"/added": {"eq": 1}}},
{"tool": "object_select", "args": {"objects": [4]}},
{"tool": "action_run", "args": {"id": "orca_command:obj_split_objects:orca"},
"expect": {"/objects/0/index": {"eq": 4}, "/objects/1/index": {"eq": 5}, "/object_count": {"eq": 6}}},
{"tool": "object_list", "expect": {"/total": {"eq": 6}}},
{"tool": "project_new", "args": {"discard_changes": true}}
]
}
-110
View File
@@ -1,110 +0,0 @@
// Assigns filaments to objects and parts through settings_set, as the object list's Change Filament
// does, and reads them back with settings_get's effective values; then sets the project's slot colours,
// flushing volumes, plate type and prime tower position with project_set_settings, reading them back with
// project_get_settings. Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/multicolor.json --out /tmp/multicolor
{
"orca_replay_version": "0.2.0",
"name": "object and part filaments",
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "dialog_auto_answer", "args": {"rules": [{"match": "unsaved changes", "button": "no"},
{"match": "restore", "button": "no"},
{"match": "Uniform scale", "button": "ok"}]}},
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "window_set", "args": {"size": [1600, 900]}},
{"tool": "view_set", "args": {"tab": "prepare"}},
// A second filament (or one more, on a datadir an earlier run left with several).
{"tool": "widget_click", "args": {"target": {"label": "Add one filament"}}},
{"tool": "app_state", "expect": {"/presets/filaments/1": {"exists": true}}},
// Object 0 a cube, object 1 a cylinder.
{"tool": "action_run", "args": {"id": "orca_command:add_primitive_cube:orca"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "action_run", "args": {"id": "orca_command:add_primitive_cylinder:orca"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "object_transform", "args": {"object": 0, "translate": [100, 100, 12.8], "mode": "absolute"}},
{"tool": "object_transform", "args": {"object": 1, "translate": [160, 100, 12.8], "mode": "absolute"}},
// ---- An object's filament, read back, undone and redone ----
{"tool": "settings_set", "args": {"target": "object", "object": 1, "values": {"extruder": 2}}, "expect": {"/applied/extruder": {"eq": "2"}}},
{"tool": "settings_get", "args": {"target": "object", "object": 1, "keys": ["extruder"]},
"expect": {"/items/0/effective": {"eq": "2"}, "/items/0/source": {"eq": "object"}}},
{"tool": "settings_get", "args": {"target": "object", "object": 0, "keys": ["extruder"]}, "expect": {"/items/0/effective": {"eq": "1"}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "settings_get", "args": {"target": "object", "object": 1, "keys": ["extruder"]}, "expect": {"/items/0/effective": {"eq": "1"}}},
{"tool": "action_run", "args": {"id": "orca_command:redo:orca"}},
{"tool": "settings_get", "args": {"target": "object", "object": 1, "keys": ["extruder"]}, "expect": {"/items/0/effective": {"eq": "2"}}},
// ---- A single-part object's part 0 is the object: its filament is set there ----
{"tool": "settings_set", "args": {"target": "part", "object": 1, "part": 0, "values": {"extruder": 1}},
"expect": {"/applied/extruder": {"eq": "1"}, "/note": {"exists": true}}},
{"tool": "settings_get", "args": {"target": "object", "object": 1, "keys": ["extruder"]}, "expect": {"/items/0/effective": {"eq": "1"}}},
{"tool": "settings_set", "args": {"target": "object", "object": 1, "values": {"extruder": 2}}},
// ---- A text part on the cube takes filament 2; the object's reply lists it apart ----
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "widget_click", "args": {"target": {"gizmo": "Text"}}, "expect": {"/created": {"eq": true}, "/active": {"eq": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "widget_click", "args": {"target": {"imgui": "Done"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/1/text": {"exists": true}}},
{"tool": "settings_set", "args": {"target": "part", "object": 0, "part": 1, "values": {"extruder": 2}}, "expect": {"/applied/extruder": {"eq": "2"}}},
{"tool": "settings_get", "args": {"target": "part", "object": 0, "part": 1, "keys": ["extruder"]},
"expect": {"/items/0/effective": {"eq": "2"}, "/items/0/source": {"eq": "part"}, "/note": {"exists": true}}},
{"tool": "settings_get", "args": {"target": "object", "object": 0, "keys": ["extruder"]},
"expect": {"/items/0/effective": {"eq": "1"}, "/items/0/parts/0/part": {"eq": 1}, "/items/0/parts/0/value": {"eq": "2"}, "/note": {"exists": true}}},
// Default on a part is its object's filament.
{"tool": "settings_set", "args": {"target": "part", "object": 0, "part": 1, "values": {"extruder": null}}, "expect": {"/applied/extruder": {"eq": "1"}}},
{"tool": "settings_set", "args": {"target": "part", "object": 0, "part": 1, "values": {"extruder": 2}}},
// ---- A filament and another setting in one call are one undo step; the object's filament clears the part's ----
{"tool": "settings_set", "args": {"target": "object", "object": 0, "values": {"extruder": 2, "wall_loops": 5}},
"expect": {"/applied/extruder": {"eq": "2"}, "/applied/wall_loops": {"eq": "5"}}},
{"tool": "settings_get", "args": {"target": "object", "object": 0, "keys": ["extruder", "wall_loops"]},
"expect": {"/items/0/effective": {"eq": "2"}, "/items/0/parts": {"exists": false}, "/items/1/source": {"eq": "object"}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "settings_get", "args": {"target": "object", "object": 0, "keys": ["extruder", "wall_loops"]},
"expect": {"/items/0/effective": {"eq": "1"}, "/items/0/parts/0/value": {"eq": "2"}, "/items/1/value": {"eq": null}, "/items/1/source": {"eq": "global"}}},
// ---- Project settings. Entries by index, since a reused datadir may start with more slots ----
{"tool": "project_get_settings", "args": {"keys": ["filament_is_mixed", "curr_bed_type", "prime_volume_mode"]},
"expect": {"/items/0/meta/read_only": {"eq": true}, "/items/0/value": {"regex": "^0,0"},
"/items/1/meta/offered": {"contains": "Textured PEI Plate"}, "/items/2/meta/offered": {"empty": true}}},
{"tool": "project_set_settings", "args": {"values": {"filament_colour": {"index": 0, "value": "#ffffff"}}},
"expect": {"/applied/filament_colour": {"regex": "^#FFFFFF;"}}},
// A colour, the multiplier, one matrix entry and the plate type in one call: the colour goes first, so its
// recalculated flushing volumes do not replace the entry given.
{"tool": "project_set_settings", "args": {"values": {"filament_colour": {"index": 1, "value": "#000000"}, "flush_multiplier": 0.7, "flush_volumes_matrix": {"index": 1, "value": 400}, "curr_bed_type": "Textured PEI Plate"}},
"expect": {"/applied/filament_colour": {"regex": "^#FFFFFF;#000000"}, "/applied/flush_multiplier": {"eq": "0.7"},
"/applied/flush_volumes_matrix": {"regex": "^0,400,"}, "/applied/curr_bed_type": {"eq": "Textured PEI Plate"}}},
{"tool": "project_get_settings", "args": {"keys": ["filament_colour", "flush_volumes_matrix", "flush_multiplier", "curr_bed_type"]},
"expect": {"/items/0/value": {"regex": "^#FFFFFF;#000000"}, "/items/1/value": {"regex": "^0,400,"}, "/items/2/value": {"eq": "0.7"},
"/items/3/value": {"eq": "Textured PEI Plate"}}},
// Refused, and nothing changes: a mixed flag, a bad colour together with a valid multiplier, a purge mode the
// X1C has no button for, a non-zero diagonal.
{"tool": "project_set_settings", "args": {"values": {"filament_is_mixed": "1"}}, "optional": true},
{"tool": "project_set_settings", "args": {"values": {"filament_colour": {"index": 0, "value": "white"}, "flush_multiplier": 0.5}},
"optional": true},
{"tool": "project_set_settings", "args": {"values": {"prime_volume_mode": "Saving"}}, "optional": true},
{"tool": "project_set_settings", "args": {"values": {"flush_volumes_matrix": {"index": 0, "value": 10}}}, "optional": true},
{"tool": "project_get_settings", "args": {"keys": ["filament_colour", "flush_multiplier", "flush_volumes_matrix", "filament_is_mixed"]},
"expect": {"/items/0/value": {"regex": "^#FFFFFF;"}, "/items/1/value": {"eq": "0.7"}, "/items/2/value": {"regex": "^0,400,"},
"/items/3/value": {"regex": "^0,0"}}},
// The prime tower of plate 0, moved twice; undo puts it back where the first move left it.
{"tool": "project_set_settings", "args": {"values": {"wipe_tower_x": {"index": 0, "value": 150}, "wipe_tower_y": {"index": 0, "value": 180}}},
"expect": {"/applied/wipe_tower_x": {"regex": "^150(,|$)"}, "/applied/wipe_tower_y": {"regex": "^180(,|$)"}}},
{"tool": "project_set_settings", "args": {"values": {"wipe_tower_x": {"index": 0, "value": 40}}},
"expect": {"/applied/wipe_tower_x": {"regex": "^40(,|$)"}}},
{"tool": "action_run", "args": {"id": "orca_command:undo:orca"}},
{"tool": "project_get_settings", "args": {"keys": ["wipe_tower_x", "wipe_tower_y"]},
"expect": {"/items/0/value": {"regex": "^150(,|$)"}, "/items/1/value": {"regex": "^180(,|$)"}}},
{"tool": "project_set_settings", "args": {"values": {"wipe_tower_x": {"index": 0, "value": 300}}}, "optional": true},
{"tool": "plate_slice", "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
{"tool": "view_set", "args": {"tab": "prepare", "camera": "iso"}},
{"tool": "window_screenshot", "args": {"target": "canvas", "save_path": "${out_dir}/filaments.png", "overwrite": true, "include_image": false}},
// The plate type is remembered per printer; back to the bench datadir's.
{"tool": "project_set_settings", "args": {"values": {"curr_bed_type": "Cool Plate"}}}
]
}
@@ -1,43 +0,0 @@
// New Project's question about the project's unsaved changes keeps the plate's layer G-code whatever the answer:
// Cancel leaves it on the project, and Save writes it to the project's file before the new project starts. Run on
// a live app:
// python3 tools/mcp/orca_mcp.py run-replay tools/mcp/tests/new_project_keeps_layer_gcode.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "new project keeps layer G-code",
"vars": {"cube": "${replay_dir}/../../../resources/handy_models/OrcaCube_v2.drc"},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "project_import", "args": {"paths": ["${vars.cube}"]}, "expect": {"/added": {"eq": 1}}},
{"tool": "object_transform", "args": {"object": 0, "size": [20, 20, 20]}},
{"tool": "plate_slice", "expect": {"/status": {"eq": "done"}, "/plates/0/outcome": {"eq": "ok"}}},
{"tool": "plate_set_custom_gcode", "args": {"add": [{"layer": 26, "type": "pause"}]},
"expect": {"/layer_gcode/0/type": {"eq": "pause"}, "/layer_gcode/1": {"exists": false}}},
// ---- Cancel: the project keeps its object and its layer G-code ----
{"tool": "action_run", "args": {"id": "orca_command:new_project:orca"}, "await": false, "save_as": "cancelled"},
{"tool": "app_wait", "args": {"for": "dialog"}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "- Save"}, "button": "cancel"}},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.cancelled}"}},
{"tool": "plate_list", "expect": {"/items/0/objects": {"eq": 1},
"/items/0/layer_gcode/0/type": {"eq": "pause"},
"/items/0/layer_gcode/1": {"exists": false}}},
// ---- Save: the project's file gets the layer G-code, and the new project starts empty ----
{"tool": "project_save", "args": {"path": "${out_dir}/kept.3mf", "overwrite": true}},
{"tool": "object_transform", "args": {"object": 0, "translate": [5, 0, 0]}},
{"tool": "action_run", "args": {"id": "orca_command:new_project:orca"}, "await": false, "save_as": "saved"},
{"tool": "app_wait", "args": {"for": "dialog"}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "- Save"}, "button": "yes"}},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.saved}"}},
{"tool": "plate_list", "expect": {"/items/0/objects": {"eq": 0}, "/items/0/layer_gcode": {"eq": []}}},
{"tool": "project_open", "args": {"path": "${out_dir}/kept.3mf", "discard_changes": true}},
{"tool": "plate_list", "expect": {"/items/0/objects": {"eq": 1},
"/items/0/layer_gcode/0/type": {"eq": "pause"},
"/items/0/layer_gcode/1": {"exists": false}}},
{"tool": "project_new", "args": {"discard_changes": true}}
]
}
-132
View File
@@ -1,132 +0,0 @@
// Clone, Reload from disk and Replace 3D file by index: object_clone makes three copies of object 0, which its reply
// names by their new indices beside the object copied, and the Clone dialog, opened through the object's menu, clones
// once more; object_clone with no targets copies a selected instance as a new object and names that instance;
// object_reload_from_disk takes the new mesh of a file overwritten in the output folder (written by
// fixtures/objects_files.py), and once the file is gone lists the part under missing with no file dialog;
// part_replace swaps a part's mesh for another file's and it keeps its type, filament and position, a modifier's and it
// stays a modifier, and with keep_painting turned on in the Preferences dialog a part keeps the supports painted on it.
// Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/objects_files.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "objects files by index",
"vars": {
"files": "${replay_dir}/fixtures/objects_files.py",
"undo": "${replay_dir}/fixtures/ops_undo.py",
"box": "${replay_dir}/../../../tests/data/test_stl/ASCII/20mmbox-LF.stl",
"same_box": "${replay_dir}/../../../tests/data/test_stl/ASCII/20mmbox-CRLF.stl"
},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "view_set", "args": {"tab": "prepare"}},
// ---- Clone: three copies of object 0, named by their new indices, arranged on the plate ----
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_clone", "args": {"objects": [0], "count": 3, "arrange": true},
"expect": {"/objects/0/index": {"eq": 1}, "/objects/2/index": {"eq": 3}, "/objects/3": {"exists": false},
"/copied/objects/0/index": {"eq": 0}, "/copied/objects/1": {"exists": false}, "/copied/instances": {"exists": false},
"/object_count": {"eq": 4}, "/arranged": {"eq": true}}},
{"tool": "object_list", "expect": {"/outside": {"empty": true}, "/plates/0/objects/3/index": {"eq": 3},
"/plates/0/objects/4": {"exists": false}}},
// ---- The Clone dialog through the object's menu clones ----
{"tool": "view_set", "args": {"camera": "iso"}},
{"tool": "view_set", "args": {"camera": "fit_objects"}},
{"tool": "object_select", "args": {"objects": [0]}},
// The 3D view draws the arranged objects before the click, so that it finds the object under the pointer.
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "mouse_gesture", "args": {"action": "click", "button": "right", "at": {"object": 0, "spot": "top"}, "popup_item": "Clone"},
"expect": {"/ran": {"eq": "Clone"}}},
{"tool": "app_wait", "args": {"for": "dialog"}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "Clone"}, "button": "ok"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "app_state", "expect": {"/dialogs": {"empty": true}}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.object_count()"},
"expect": {"/result/count": {"eq": 5}}},
// ---- Clone with no targets: the selected instance is copied as a new object, and the reply names it ----
{"tool": "object_set_instances", "args": {"object": 2, "count": 2}},
{"tool": "object_select", "args": {"instances": [[2, 1]]}},
{"tool": "object_clone", "args": {"arrange": true},
"expect": {"/copied/instances/0/object": {"eq": 2}, "/copied/instances/0/instance": {"eq": 1},
"/copied/instances/1": {"exists": false}, "/copied/objects": {"exists": false},
"/objects/0/index": {"eq": 5}, "/objects/1": {"exists": false}, "/object_count": {"eq": 6}}},
{"tool": "object_list", "expect": {"/plates/0/objects/5/instances/0": {"exists": true}, "/plates/0/objects/5/instances/1": {"exists": false},
"/plates/0/objects/2/instances/1": {"exists": true}}},
// ---- Reload from disk: a file overwritten with a bigger cube, then removed ----
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.import_cube(args)",
"args": {"name": "reload.stl", "size": 20}},
"expect": {"/result/import/added": {"eq": 1}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/mesh_volume": {"eq": 8000}}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.write_cube(args)",
"args": {"name": "reload.stl", "size": 30}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "object_reload_from_disk", "args": {"objects": [0]},
"expect": {"/reloaded/0/object": {"eq": 0}, "/reloaded/0/part": {"eq": 0}, "/reloaded/0/path": {"contains": "reload.stl"},
"/reloaded/1": {"exists": false}, "/missing": {"empty": true}, "/unmatched": {"empty": true},
"/unreadable": {"exists": false}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/mesh_volume": {"eq": 27000}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"},
"expect": {"/result/taken": {"eq": ["Reload from disk"]}}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.remove(args)",
"args": {"name": "reload.stl"}},
"expect": {"/result/removed": {"eq": true}}},
{"tool": "object_reload_from_disk", "args": {"objects": [0]},
"expect": {"/missing/0/object": {"eq": 0}, "/missing/0/part": {"eq": 0}, "/missing/0/path": {"contains": "reload.stl"},
"/reloaded": {"empty": true}}},
{"tool": "app_state", "expect": {"/dialogs": {"empty": true}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/mesh_volume": {"eq": 27000}}},
// ---- Replace 3D file: a part and a modifier keep their type, filament and position ----
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "filament_add", "args": {}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.import_cube(args)",
"args": {"name": "replace.stl", "size": 20}}},
{"tool": "part_add", "args": {"object": 0, "type": "modifier", "shape": "cylinder", "size": [10, 10]}},
{"tool": "settings_set", "args": {"type": "process", "target": "part", "object": 0, "part": 0, "values": {"extruder": 2}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/filament": {"eq": 2}, "/plates/0/objects/0/parts/1/type": {"eq": "modifier"},
"/plates/0/objects/0/parts/1/mesh_volume": {"lt": 7999}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.replace_keeps(args)",
"args": {"object": 0, "part": 0, "path": "${vars.box}"}},
"expect": {"/result/reply/parts/0/object": {"eq": 0}, "/result/reply/parts/0/part": {"eq": 0},
"/result/reply/parts/0/name": {"contains": "20mmbox"}, "/result/same_id": {"eq": false},
"/result/type": {"eq": "part"}, "/result/filament": {"eq": 2}, "/result/moved": {"lt": 0.01}}},
// The new mesh keeps the old one's place in its file: the cylinder was made centred, the box file's corner is at its
// origin, so the modifier moves by that difference.
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.replace_keeps(args)",
"args": {"object": 0, "part": 1, "path": "${vars.box}"}},
"expect": {"/result/reply/parts/0/part": {"eq": 1}, "/result/reply/part_info/mesh_volume": {"eq": 8000},
"/result/type": {"eq": "modifier"}, "/result/same_filament": {"eq": true}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"},
"expect": {"/result/taken": {"eq": ["Replace with 3D file", "Replace with 3D file"]}}},
// ---- Replace 3D file with keep_painting on: the supports painted on the part stay ----
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.import_cube(args)",
"args": {"name": "painted.stl", "size": 20}}},
{"tool": "view_set", "args": {"camera": "front"}},
{"tool": "view_set", "args": {"camera": "fit_objects"}},
{"tool": "object_select", "args": {"objects": [0]}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "widget_click", "args": {"target": {"gizmo": "FdmSupports"}}, "expect": {"/active": {"eq": true}}},
{"tool": "widget_click", "args": {"target": {"imgui_name": "Fill"}}},
{"tool": "mouse_gesture", "args": {"at": {"object": 0, "spot": "front"}}},
{"tool": "widget_click", "args": {"target": {"imgui": "Done"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/supports/enforcers": {"gt": 0}}},
{"tool": "window_open", "args": {"window": "preferences", "tab": "developer", "key": "keep_painting"}, "await": false, "save_as": "prefs"},
{"tool": "widget_click", "args": {"target": {"name": "keep_painting", "within": "Preferences"}}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "Preferences"}, "button": "close"}},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.prefs}"}},
{"tool": "preferences_get", "args": {"keys": ["keep_painting"]}, "expect": {"/items/0/value": {"eq": true}}},
{"tool": "part_replace", "args": {"object": 0, "part": 0, "path": "${vars.same_box}"},
"expect": {"/parts/0/name": {"contains": "20mmbox"}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/parts/0/painted/supports/enforcers": {"gt": 0}}},
{"tool": "project_new", "args": {"discard_changes": true}}
]
}
-47
View File
@@ -1,47 +0,0 @@
// object_order with order: three objects on a plate put in the order [2, 0, 1], as dragging them in the object list
// does. Its reply and object_list give the new order, which is the print order of a plate that prints by object
// (plate_set_settings print_sequence); the order they have already changes nothing, and one undo restores the order
// before. Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/objects_order.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "objects in a given order",
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "view_set", "args": {"tab": "prepare"}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_rename", "args": {"object": 0, "name": "first"}},
{"tool": "object_rename", "args": {"object": 1, "name": "second"}},
{"tool": "object_rename", "args": {"object": 2, "name": "third"}},
{"tool": "plate_set_settings", "args": {"plate": 0, "values": {"print_sequence": "by object"}},
"expect": {"/applied/print_sequence": {"eq": "by object"}}},
{"tool": "object_list", "expect": {"/total": {"eq": 3}, "/plates/0/objects/0/name": {"eq": "first"},
"/plates/0/objects/1/name": {"eq": "second"}, "/plates/0/objects/2/name": {"eq": "third"}}},
// ---- The order [2, 0, 1]: the reply and the object list name them in it, by their indices afterwards ----
{"tool": "object_order", "args": {"plate": 0, "order": [2, 0, 1]},
"expect": {"/order/0/name": {"eq": "third"}, "/order/0/object": {"eq": 0}, "/order/1/name": {"eq": "first"},
"/order/1/object": {"eq": 1}, "/order/2/name": {"eq": "second"}, "/order/2/object": {"eq": 2},
"/order/3": {"exists": false}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/name": {"eq": "third"}, "/plates/0/objects/1/name": {"eq": "first"},
"/plates/0/objects/2/name": {"eq": "second"}}},
{"tool": "plate_list", "expect": {"/items/0/print_sequence": {"eq": "by object"}, "/items/0/objects": {"eq": 3}}},
// ---- The order they have changes nothing ----
{"tool": "object_order", "args": {"order": [0, 1, 2]},
"expect": {"/order/0/name": {"eq": "third"}, "/order/1/name": {"eq": "first"}, "/order/2/name": {"eq": "second"}}},
// ---- One undo step restores the order before ----
{"tool": "undo", "args": {}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/name": {"eq": "first"}, "/plates/0/objects/1/name": {"eq": "second"},
"/plates/0/objects/2/name": {"eq": "third"}}},
{"tool": "project_new", "args": {"discard_changes": true}}
]
}
-93
View File
@@ -1,93 +0,0 @@
// Printable, Fix Model and Auto Drop by index: object_set_printable marks one instance of three not printable, which
// object_list reads, beside its two siblings and another object that stay printable, and one undo takes it back;
// object_fix repairs a cube that lacks a triangle (written and imported by fixtures/objects_files.py), whose open edges
// object_list reads before and after, with no dialog and no notice, in one "Repairing model object" undo step
// (fixtures/ops_undo.py); Fix Model through the object's menu ends in its notice; object_set_auto_drop off lets a
// lifted object stay above the bed, where with Auto Drop on it drops. Run it with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/objects_state.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "objects state by index",
"vars": {
"files": "${replay_dir}/fixtures/objects_files.py",
"undo": "${replay_dir}/fixtures/ops_undo.py"
},
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "view_set", "args": {"tab": "prepare"}},
// ---- Printable: object 0 of three instances beside object 1 ----
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_set_instances", "args": {"object": 0, "count": 3}},
{"tool": "object_add_primitive", "args": {"shape": "cube", "size": [20, 20, 20]}},
{"tool": "object_select", "args": {"none": true}},
{"tool": "object_arrange", "args": {}},
{"tool": "object_list", "expect": {"/outside": {"empty": true}, "/plates/0/objects/0/instances/2/index": {"eq": 2},
"/plates/0/objects/1/index": {"eq": 1}}},
{"tool": "object_set_printable", "args": {"instances": [[0, 1]], "printable": false},
"expect": {"/instances/0/object": {"eq": 0}, "/instances/0/instance": {"eq": 1}, "/instances/0/printable": {"eq": false},
"/instances/1": {"exists": false}, "/objects": {"exists": false}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/instances/1/printable": {"eq": false},
"/plates/0/objects/0/instances/0/printable": {"eq": true},
"/plates/0/objects/0/instances/2/printable": {"eq": true},
"/plates/0/objects/1/instances/0/printable": {"eq": true}}},
{"tool": "undo", "args": {"history": "project"}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/instances/1/printable": {"eq": true}}},
// An object named sets every instance of it, and no other object's.
{"tool": "object_set_printable", "args": {"objects": [0], "printable": false},
"expect": {"/objects/0/index": {"eq": 0}, "/instances/2/instance": {"eq": 2}, "/instances/3": {"exists": false}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/instances/0/printable": {"eq": false},
"/plates/0/objects/0/instances/2/printable": {"eq": false},
"/plates/0/objects/1/instances/0/printable": {"eq": true}}},
// ---- Fix Model: a cube with a hole, repaired by index with no dialog and no notice ----
{"tool": "project_new", "args": {"discard_changes": true}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.import_cube(args)",
"args": {"name": "holed.stl", "size": 20, "holed": true}},
"expect": {"/result/import/added": {"eq": 1}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/mesh_errors/open_edges": {"gt": 0},
"/plates/0/objects/0/mesh_errors/manifold": {"eq": false}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
{"tool": "object_fix", "args": {"objects": [0]},
"expect": {"/status": {"exists": false}, "/objects/0/index": {"eq": 0}, "/repairs/0/changed": {"eq": true},
"/repairs/0/mesh_errors_before/open_edges": {"gt": 0}, "/repairs/0/mesh_errors_after/open_edges": {"eq": 0}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/mesh_errors/open_edges": {"eq": 0},
"/plates/0/objects/0/mesh_errors/manifold": {"eq": true}}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.repair_notices()"},
"expect": {"/result/notices": {"empty": true}, "/result/dialogs": {"empty": true}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"},
"expect": {"/result/taken": {"eq": ["Repairing model object"]}}},
// ---- Fix Model through the object's menu: the person's path ends in its notice ----
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.import_cube(args)",
"args": {"name": "holed_menu.stl", "size": 20, "holed": true}}},
{"tool": "object_transform", "args": {"object": 0, "position": [60, 60, 10], "mode": "absolute"}},
{"tool": "object_transform", "args": {"object": 1, "position": [128, 128, 10], "mode": "absolute"}},
{"tool": "object_list", "expect": {"/plates/0/objects/1/mesh_errors/open_edges": {"gt": 0}}},
{"tool": "view_set", "args": {"camera": "iso"}},
{"tool": "view_set", "args": {"camera": "fit_objects"}},
{"tool": "object_select", "args": {"objects": [1]}},
// The 3D view draws the moved objects before the click, so that it finds the object under the pointer.
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "mouse_gesture", "args": {"action": "click", "button": "right", "at": {"object": 1, "spot": "top"}, "popup_item": "Modify>Fix Model"},
"expect": {"/ran": {"eq": "Modify>Fix Model"}}},
{"tool": "script_run", "args": {"filename": "${vars.files}", "code": "import objects_files\nresult = objects_files.wait_repaired(args)",
"args": {"object": 1}},
"expect": {"/result/mesh_errors/open_edges": {"eq": 0}, "/result/notices/0": {"contains": "has been repaired"}}},
{"tool": "script_run", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"},
"expect": {"/result/taken": {"contains": "Repairing model object"}}},
// ---- Auto Drop: with it on a lifted object drops, with it off it stays where it is moved ----
{"tool": "object_transform", "args": {"object": 0, "translate": [0, 0, 15]}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/bbox/min/2": {"lt": 0.01}}},
{"tool": "object_set_auto_drop", "args": {"objects": [0], "auto_drop": false},
"expect": {"/objects/0/index": {"eq": 0}, "/objects/1": {"exists": false}, "/auto_drop": {"eq": false}}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/auto_drop": {"eq": false}, "/plates/0/objects/1/auto_drop": {"eq": true}}},
{"tool": "object_transform", "args": {"object": 0, "translate": [0, 0, 15]}},
{"tool": "object_list", "expect": {"/plates/0/objects/0/bbox/min/2": {"gt": 14.99}, "/plates/0/objects/0/bbox/max/2": {"lt": 35.01}}},
{"tool": "project_new", "args": {"discard_changes": true}}
]
}
@@ -1,414 +0,0 @@
// Records the assignment of a filament preset to a slot on a printer with three slots. Slot 2 is assigned
// through each route: a pick in its selector in the sidebar (its list opened with widget_click and the row
// clicked), preset_select, and the plugin API's orca.host.preset.filament.begin_update(2, name) run from
// script_run; for an ordinary change to a filament with a default colour and to one without, and for a change to
// a support filament, under each value of the automatic flush calculation (Preferences > Behaviour > Auto flush
// after changing...). Then the plugin API's other forms, unsaved changes in the preset the filament tab edits,
// the refusals (no such slot, no such name, an incompatible preset, a mixed-colour slot) and a hidden preset. Each
// case starts from slot presets, colours and flushing volumes set to sentinels by fixtures/ops_presets.py, and
// after each call reads what it left once queued events have settled (the slot mapping, the edited filament
// preset, the three colour settings, the project's colours and flushing volumes, dialogs, undo snapshots).
// Refused calls are optional. Run it on a freshly launched app (a hidden preset stays shown until a restart)
// with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/ops_assign_filament_preset_multi_slot.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "ops assign_filament_preset, several slots",
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "window_set", "args": {"size": [1600, 900]}},
{"tool": "view_set", "args": {"tab": "prepare"}},
// Simple mode, as on a fresh datadir: the unsaved-changes prompt lists the settings the mode shows.
{"tool": "action_run", "args": {"id": "orca_command:mode_simple:orca"}},
// One slot first, so the presets below are shown and selected on the harness's default printer.
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "preset_select", "args": {"type": "printer", "name": "Bambu Lab X1 Carbon 0.4 nozzle", "preset_changes": "discard"}},
{"tool": "preset_select", "args": {"type": "process", "name": "0.20mm Standard @BBL X1C", "preset_changes": "discard"}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu PLA Basic", "filament_slot": 1, "preset_changes": "discard"}},
// The filaments the cases pick, hidden on a fresh datadir, are shown in every selector (until the app
// restarts) by selecting each once with the tool. FilAr PLA Blanco Calido has a default colour
// (#FFF8E7); the Bambu ones have none.
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 1}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu PLA Matte", "filament_slot": 1}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu Support For PLA", "filament_slot": 1}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu Support for ABS", "filament_slot": 1}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu PLA Basic", "filament_slot": 1}},
{"tool": "action_run", "args": {"id": "orca_command:filament_add:orca"}},
{"tool": "action_run", "args": {"id": "orca_command:filament_add:orca"}},
{"tool": "app_state", "expect": {"/presets/filaments/2": {"exists": true}, "/presets/filaments/3": {"exists": false}}},
// ==== Automatic flush calculation "All" (all) ====
{"tool": "window_open", "args": {"window": "preferences", "tab": "behaviour", "key": "auto_calculate_flush"}, "await": false, "save_as": "prefs1"},
// The choice is saved by the drop-down's own handler, so it is picked from its list.
{"tool": "widget_click", "args": {"target": {"name": "auto_calculate_flush", "within": "Preferences"}}},
{"tool": "widget_click", "args": {"target": {"row": "All"}}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "Preferences"}, "button": "close"}},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.prefs1}"}},
{"tool": "preferences_get", "args": {"keys": ["auto_calculate_flush"]}, "expect": {"/items/0/value": {"eq": "all"}}},
// ---- Slot 2, an ordinary change to a filament with a default colour: FilAr PLA Blanco Calido ----
// Picked in slot 2's selector, its list opened with a click and the row clicked.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 2}}},
{"tool": "widget_click", "args": {"target": {"row": "FilAr PLA Blanco Calido"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The tool.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 2}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The plugin API, begin_update(2, name) and commit().
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "FilAr PLA Blanco Calido", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Slot 2, an ordinary change to a filament without one: Bambu PLA Matte ----
// Picked in slot 2's selector, its list opened with a click and the row clicked.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 2}}},
{"tool": "widget_click", "args": {"target": {"row": "Bambu PLA Matte"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The tool.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu PLA Matte", "filament_slot": 2}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The plugin API, begin_update(2, name) and commit().
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "Bambu PLA Matte", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Slot 2, a change that makes the slot hold a support filament: Bambu Support For PLA ----
// Picked in slot 2's selector, its list opened with a click and the row clicked.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 2}}},
{"tool": "widget_click", "args": {"target": {"row": "Bambu Support For PLA"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The tool.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu Support For PLA", "filament_slot": 2}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The plugin API, begin_update(2, name) and commit().
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "Bambu Support For PLA", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ==== Automatic flush calculation "Color" (color change) ====
{"tool": "window_open", "args": {"window": "preferences", "tab": "behaviour", "key": "auto_calculate_flush"}, "await": false, "save_as": "prefs2"},
// The choice is saved by the drop-down's own handler, so it is picked from its list.
{"tool": "widget_click", "args": {"target": {"name": "auto_calculate_flush", "within": "Preferences"}}},
{"tool": "widget_click", "args": {"target": {"row": "Color"}}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "Preferences"}, "button": "close"}},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.prefs2}"}},
{"tool": "preferences_get", "args": {"keys": ["auto_calculate_flush"]}, "expect": {"/items/0/value": {"eq": "color change"}}},
// ---- Slot 2, an ordinary change to a filament with a default colour: FilAr PLA Blanco Calido ----
// Picked in slot 2's selector, its list opened with a click and the row clicked.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 2}}},
{"tool": "widget_click", "args": {"target": {"row": "FilAr PLA Blanco Calido"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The tool.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 2}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The plugin API, begin_update(2, name) and commit().
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "FilAr PLA Blanco Calido", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Slot 2, an ordinary change to a filament without one: Bambu PLA Matte ----
// Picked in slot 2's selector, its list opened with a click and the row clicked.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 2}}},
{"tool": "widget_click", "args": {"target": {"row": "Bambu PLA Matte"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The tool.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu PLA Matte", "filament_slot": 2}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The plugin API, begin_update(2, name) and commit().
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "Bambu PLA Matte", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Slot 2, a change that makes the slot hold a support filament: Bambu Support For PLA ----
// Picked in slot 2's selector, its list opened with a click and the row clicked.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 2}}},
{"tool": "widget_click", "args": {"target": {"row": "Bambu Support For PLA"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The tool.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu Support For PLA", "filament_slot": 2}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The plugin API, begin_update(2, name) and commit().
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "Bambu Support For PLA", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ==== Automatic flush calculation "None" (disabled) ====
{"tool": "window_open", "args": {"window": "preferences", "tab": "behaviour", "key": "auto_calculate_flush"}, "await": false, "save_as": "prefs3"},
// The choice is saved by the drop-down's own handler, so it is picked from its list.
{"tool": "widget_click", "args": {"target": {"name": "auto_calculate_flush", "within": "Preferences"}}},
{"tool": "widget_click", "args": {"target": {"row": "None"}}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "Preferences"}, "button": "close"}},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.prefs3}"}},
{"tool": "preferences_get", "args": {"keys": ["auto_calculate_flush"]}, "expect": {"/items/0/value": {"eq": "disabled"}}},
// ---- Slot 2, an ordinary change to a filament with a default colour: FilAr PLA Blanco Calido ----
// Picked in slot 2's selector, its list opened with a click and the row clicked.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 2}}},
{"tool": "widget_click", "args": {"target": {"row": "FilAr PLA Blanco Calido"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The tool.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 2}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The plugin API, begin_update(2, name) and commit().
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "FilAr PLA Blanco Calido", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Slot 2, an ordinary change to a filament without one: Bambu PLA Matte ----
// Picked in slot 2's selector, its list opened with a click and the row clicked.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 2}}},
{"tool": "widget_click", "args": {"target": {"row": "Bambu PLA Matte"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The tool.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu PLA Matte", "filament_slot": 2}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The plugin API, begin_update(2, name) and commit().
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "Bambu PLA Matte", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Slot 2, a change that makes the slot hold a support filament: Bambu Support For PLA ----
// Picked in slot 2's selector, its list opened with a click and the row clicked.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 2}}},
{"tool": "widget_click", "args": {"target": {"row": "Bambu Support For PLA"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The tool.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu Support For PLA", "filament_slot": 2}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The plugin API, begin_update(2, name) and commit().
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "Bambu Support For PLA", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ==== Back to "All": the other forms, unsaved changes, refusals ====
{"tool": "window_open", "args": {"window": "preferences", "tab": "behaviour", "key": "auto_calculate_flush"}, "await": false, "save_as": "prefs4"},
// The choice is saved by the drop-down's own handler, so it is picked from its list.
{"tool": "widget_click", "args": {"target": {"name": "auto_calculate_flush", "within": "Preferences"}}},
{"tool": "widget_click", "args": {"target": {"row": "All"}}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "Preferences"}, "button": "close"}},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.prefs4}"}},
{"tool": "preferences_get", "args": {"keys": ["auto_calculate_flush"]}, "expect": {"/items/0/value": {"eq": "all"}}},
// ---- The selector's value set with widget_set_value, which also reaches both handlers ----
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "widget_set_value", "args": {"target": {"class": "PlaterPresetComboBox", "index": 2}, "value": "FilAr PLA Blanco Calido"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- The plugin API's other forms. begin_update(2, name) without commit(): it assigns at once ----
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "FilAr PLA Blanco Calido"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// begin_update(2, name) naming the preset slot 2 already holds: the tab switches, nothing is assigned.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Matte", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "Bambu PLA Matte", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// begin_update(2) with no name, slot 2 holding another preset than the tab edits.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Matte", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// begin_update(2) with a setting staged and committed.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Matte", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "set": ["slow_down_layer_time", "8"], "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// update(2, key, value).
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Matte", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "update", "slot": 2, "key": "slow_down_layer_time", "value": "8"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// update(key, value): the preset the tab edits.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Matte", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "update", "key": "slow_down_layer_time", "value": "8"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Unsaved changes in the preset the tab edits (slot 1's): only the plugin API switches the tab ----
// The sidebar.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 2}}},
{"tool": "widget_click", "args": {"target": {"row": "FilAr PLA Blanco Calido"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The tool without preset_changes, then with each value.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 2}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 2, "preset_changes": "transfer"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 2, "preset_changes": "discard"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The plugin API, begin_update(2, name) and commit(): the prompt answered Transfer, Discard and closed.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "FilAr PLA Blanco Calido", "commit": true}}, "await": false, "save_as": "api5"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "Transfer"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api5}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api5}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "FilAr PLA Blanco Calido", "commit": true}}, "await": false, "save_as": "api6"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "Discard"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api6}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api6}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "FilAr PLA Blanco Calido", "commit": true}}, "await": false, "save_as": "api7"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api7}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api7}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// begin_update(2) and update(2, key, value), slot 2 holding another preset: the prompt closed.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Matte", "Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "commit": true}}, "await": false, "save_as": "api8"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api8}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api8}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Matte", "Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "update", "slot": 2, "key": "slow_down_layer_time", "value": "8"}}, "await": false, "save_as": "api9"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api9}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api9}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Refusals. A slot the project lacks ----
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 5}, "optional": true},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 5, "name": "FilAr PLA Blanco Calido", "commit": true}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 0, "name": "FilAr PLA Blanco Calido", "commit": true}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "update", "slot": 5, "key": "slow_down_layer_time", "value": "8"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// A name that matches nothing.
{"tool": "preset_select", "args": {"type": "filament", "name": "No Such Filament", "filament_slot": 2}, "optional": true},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "No Such Filament", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// A preset that is not compatible with the printer.
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu PLA Basic @BBL A1", "filament_slot": 2}, "optional": true},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "Bambu PLA Basic @BBL A1", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// A hidden preset is shown and assigned: the plugin API takes Bambu PETG HF, the tool Bambu PETG Basic
// (on a rerun without a restart both are shown already).
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 2, "name": "Bambu PETG HF @BBL X1C", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu PETG Basic", "filament_slot": 2}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// The filament editor's begin_update() takes a slot number first.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "name": "FilAr PLA Blanco Calido"}}},
// A mixed-colour slot (slot 4, made from slots 1 and 2 in the Add Mixed Filament dialog).
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic", "Bambu PLA Basic", "Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0,777,777,777,0,777,777,777,0"}}},
{"tool": "widget_click", "args": {"target": {"label": "Add Mixed Filament"}}, "await": false, "save_as": "mix10"},
{"tool": "app_wait", "args": {"for": "dialog"}},
{"tool": "app_state", "expect": {"/dialogs/0/title": {"eq": "Add Mixed Filament"}}},
{"tool": "dialog_answer", "args": {"button": "OK"}},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.mix10}"}},
{"tool": "project_get_settings", "args": {"keys": ["filament_is_mixed"]}, "expect": {"/items/0/value": {"eq": "0,0,0,1"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 4}, "optional": true},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 4, "name": "FilAr PLA Blanco Calido", "commit": true}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 4, "commit": true}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "update", "slot": 4, "key": "slow_down_layer_time", "value": "8"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "widget_click", "args": {"target": {"label": "Remove last mixed filament"}}},
{"tool": "project_get_settings", "args": {"keys": ["filament_is_mixed"]}, "expect": {"/items/0/value": {"eq": "0,0,0"}}},
// ---- Back to the harness's default printer with one slot ----
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.drop_filament_edits()"}},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "preset_select", "args": {"type": "printer", "name": "Bambu Lab X1 Carbon 0.4 nozzle", "preset_changes": "discard"}},
{"tool": "preset_select", "args": {"type": "process", "name": "0.20mm Standard @BBL X1C", "preset_changes": "discard"}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu PLA Basic", "filament_slot": 1, "preset_changes": "discard"}}
]
}
@@ -1,312 +0,0 @@
// Records the assignment of a filament preset to the only slot of a printer, where the assignment also switches
// the filament tab and its unsaved-changes prompt applies. Slot 1 is assigned through each route: a pick in its
// selector in the sidebar (its list opened with widget_click and the row clicked), preset_select, and the
// plugin API's orca.host.preset.filament.begin_update(1, name) run from script_run; for an ordinary change and
// for a change to a support filament of another type, without and with unsaved changes in the edited filament
// preset (preset_select's preset_changes values and none; the prompt answered each way, counted, and read while it is
// open). Then the plugin API's forms that name no preset. Each case starts from fixtures/ops_presets.py's
// sentinels and reads what the call left once queued events have settled. The flush calculation stays "All":
// with one slot the flushing volumes matrix has no entry to recalculate. Run it on a freshly launched app with
// tools/mcp/orca_mcp.py run-replay tools/mcp/tests/ops_assign_filament_preset_one_slot.json --out <dir>
{
"orca_replay_version": "0.2.0",
"name": "ops assign_filament_preset, one slot",
"steps": [
{"tool": "app_wait", "args": {"for": "ready"}},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "window_set", "args": {"size": [1600, 900]}},
{"tool": "view_set", "args": {"tab": "prepare"}},
// Simple mode, as on a fresh datadir: the unsaved-changes prompt lists the settings the mode shows.
{"tool": "action_run", "args": {"id": "orca_command:mode_simple:orca"}},
// One slot first, so the presets below are shown and selected on the harness's default printer.
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "preset_select", "args": {"type": "printer", "name": "Bambu Lab X1 Carbon 0.4 nozzle", "preset_changes": "discard"}},
{"tool": "preset_select", "args": {"type": "process", "name": "0.20mm Standard @BBL X1C", "preset_changes": "discard"}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu PLA Basic", "filament_slot": 1, "preset_changes": "discard"}},
// The filaments the cases pick, hidden on a fresh datadir, are shown in every selector (until the app
// restarts) by selecting each once with the tool. FilAr PLA Blanco Calido has a default colour
// (#FFF8E7); the Bambu ones have none.
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 1}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu PLA Matte", "filament_slot": 1}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu Support For PLA", "filament_slot": 1}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu Support for ABS", "filament_slot": 1}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu PLA Basic", "filament_slot": 1}},
{"tool": "app_state", "expect": {"/presets/filaments/0": {"exists": true}, "/presets/filaments/1": {"exists": false}}},
{"tool": "window_open", "args": {"window": "preferences", "tab": "behaviour", "key": "auto_calculate_flush"}, "await": false, "save_as": "prefs1"},
// The choice is saved by the drop-down's own handler, so it is picked from its list.
{"tool": "widget_click", "args": {"target": {"name": "auto_calculate_flush", "within": "Preferences"}}},
{"tool": "widget_click", "args": {"target": {"row": "All"}}},
{"tool": "dialog_answer", "args": {"dialog": {"title": "Preferences"}, "button": "close"}},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.prefs1}"}},
{"tool": "preferences_get", "args": {"keys": ["auto_calculate_flush"]}, "expect": {"/items/0/value": {"eq": "all"}}},
// ==== FilAr PLA Blanco Calido: an ordinary change (PLA to PLA, Transfer offered) ====
// ---- No unsaved changes: the sidebar, the tool, the plugin API ----
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 1}}},
{"tool": "widget_click", "args": {"target": {"row": "FilAr PLA Blanco Calido"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 1}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 1, "name": "FilAr PLA Blanco Calido", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Unsaved changes, the sidebar: the prompt answered Transfer, Discard, cancel ----
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 1}}},
{"tool": "widget_click", "args": {"target": {"row": "FilAr PLA Blanco Calido"}}, "await": false, "save_as": "pick2"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "Transfer"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.pick2}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.pick2}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 1}}},
{"tool": "widget_click", "args": {"target": {"row": "FilAr PLA Blanco Calido"}}, "await": false, "save_as": "pick3"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "Discard"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.pick3}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.pick3}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 1}}},
{"tool": "widget_click", "args": {"target": {"row": "FilAr PLA Blanco Calido"}}, "await": false, "save_as": "pick4"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.pick4}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.pick4}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Unsaved changes, the tool: preset_changes transfer and discard, then none and the prompt ----
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 1, "preset_changes": "transfer"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 1, "preset_changes": "discard"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 1}, "await": false, "save_as": "tool5"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "Transfer"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.tool5}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.tool5}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 1}, "await": false, "save_as": "tool6"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "Discard"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.tool6}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.tool6}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "FilAr PLA Blanco Calido", "filament_slot": 1}, "await": false, "save_as": "tool7"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.tool7}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.tool7}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Unsaved changes, the plugin API: begin_update(1, name) and commit() ----
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 1, "name": "FilAr PLA Blanco Calido", "commit": true}}, "await": false, "save_as": "api8"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "Transfer"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api8}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api8}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 1, "name": "FilAr PLA Blanco Calido", "commit": true}}, "await": false, "save_as": "api9"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "Discard"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api9}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api9}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 1, "name": "FilAr PLA Blanco Calido", "commit": true}}, "await": false, "save_as": "api10"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api10}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api10}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ==== Bambu Support for ABS: a change to a support filament of another type (no Transfer) ====
// ---- No unsaved changes: the sidebar, the tool, the plugin API ----
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 1}}},
{"tool": "widget_click", "args": {"target": {"row": "Bambu Support for ABS"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu Support for ABS", "filament_slot": 1}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 1, "name": "Bambu Support for ABS", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Unsaved changes, the sidebar: the prompt answered Discard, cancel ----
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 1}}},
{"tool": "widget_click", "args": {"target": {"row": "Bambu Support for ABS"}}, "await": false, "save_as": "pick11"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "Discard"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.pick11}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.pick11}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "widget_click", "args": {"target": {"class": "PlaterPresetComboBox", "index": 1}}},
{"tool": "widget_click", "args": {"target": {"row": "Bambu Support for ABS"}}, "await": false, "save_as": "pick12"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.pick12}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.pick12}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Unsaved changes, the tool: preset_changes transfer and discard, then none and the prompt ----
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu Support for ABS", "filament_slot": 1, "preset_changes": "transfer"}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu Support for ABS", "filament_slot": 1, "preset_changes": "discard"}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu Support for ABS", "filament_slot": 1}, "await": false, "save_as": "tool13"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "Discard"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.tool13}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.tool13}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu Support for ABS", "filament_slot": 1}, "await": false, "save_as": "tool14"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.tool14}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.tool14}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Unsaved changes, the plugin API: begin_update(1, name) and commit() ----
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 1, "name": "Bambu Support for ABS", "commit": true}}, "await": false, "save_as": "api15"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "Discard"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api15}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api15}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 1, "name": "Bambu Support for ABS", "commit": true}}, "await": false, "save_as": "api16"},
{"tool": "app_wait", "args": {"for": "dialog", "timeout_s": 10}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
// A second prompt, if one opens, holds the call past this wait; it is counted here and answered so the call can end.
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api16}", "timeout_s": 3}, "optional": true},
{"tool": "dialog_answer", "args": {"button": "cancel"}, "optional": true},
{"tool": "app_wait", "args": {"for": "job", "job": "${jobs.api16}", "timeout_s": 30}, "optional": true},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ==== The plugin API's forms that name no preset: the tab already edits slot 1's preset ====
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 1, "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "update", "slot": 1, "key": "slow_down_layer_time", "value": "8"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"]}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "update", "key": "slow_down_layer_time", "value": "8"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 1, "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "update", "slot": 1, "key": "slow_down_layer_time", "value": "8"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "update", "key": "slow_down_layer_time", "value": "8"}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// begin_update(1, name) naming the preset the slot holds, with unsaved changes: no switch, no prompt.
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.arrange_filaments(args)", "args": {"slots": ["Bambu PLA Basic"], "dirty": true}}, "expect": {"/result/dialogs": {"empty": true}, "/result/project/flush_volumes_matrix": {"eq": "0"}, "/result/filament_tab": {"regex": " \\(modified\\)$"}}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.preset_api(args)", "args": {"editor": "filament", "form": "begin_update", "slot": 1, "name": "Bambu PLA Basic", "commit": true}}},
{"tool": "app_wait", "args": {"for": "idle"}},
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.probe()"}},
// ---- Back to the harness's default state ----
{"tool": "script_run", "args": {"filename": "${replay_dir}/fixtures/ops_presets.py", "code": "import ops_presets\nresult = ops_presets.drop_filament_edits()"}},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "action_run", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "project_new", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "preset_select", "args": {"type": "printer", "name": "Bambu Lab X1 Carbon 0.4 nozzle", "preset_changes": "discard"}},
{"tool": "preset_select", "args": {"type": "process", "name": "0.20mm Standard @BBL X1C", "preset_changes": "discard"}},
{"tool": "preset_select", "args": {"type": "filament", "name": "Bambu PLA Basic", "filament_slot": 1, "preset_changes": "discard"}}
]
}
Loaded 100 of 112 files, more files were not shown because too many files have changed in this diff. Show more