Files
OrcaSlicer/tools/mcp/tests/context_menus.json
T
SoftFever 8bb18e84bf List objects by plate over MCP and call a part "part" in every tool
list_objects replies as the Objects panel is laid out: each plate with the
objects on it, then the objects on no plate. list_plates gives how many
objects a plate has, and every tool refuses a plate the project lacks in the
same words.
2026-11-11 18:31:00 +08:00

65 lines
4.3 KiB
JSON

// 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": 1,
"name": "context menus",
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "auto_answer_dialogs", "args": {"rules": [
{"match": "Uniform scale", "button": "ok"},
{"match": "per-object setting mode", "button": "ok"}]}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca"}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "set_view", "args": {"camera": "iso"}},
// ---- A right click on the cube lists the object menu; nothing is shown ----
{"tool": "mouse_gesture", "args": {"action": "click", "button": "right", "at": {"object": 0, "spot": "top"}},
"expect": {"/popup_menu/items": {"contains": "Add Modifier>Cylinder"}, "/popup_menu/checked": {"contains": "Printable"}}},
{"tool": "get_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, "spot": "top"}, "popup_item": "add modifier>cylinder"},
"expect": {"/ran": {"eq": "Add Modifier>Cylinder"}}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "list_objects", "expect": {"/plates/0/objects/0/parts/1/type": {"eq": "modifier"}}},
{"tool": "run_action", "args": {"id": "orca_command:undo:orca"}},
{"tool": "list_objects", "expect": {"/plates/0/objects/0/parts/1": {"exists": false}}},
{"tool": "run_action", "args": {"id": "orca_command:redo:orca"}},
{"tool": "list_objects", "expect": {"/plates/0/objects/0/parts/1/type": {"eq": "modifier"}}},
// ---- Empty space with nothing selected: the default menu ----
{"tool": "select_objects", "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": "wait", "args": {"for": "idle"}},
{"tool": "get_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": "click", "args": {"target": {"label": "Add one filament"}}},
{"tool": "click", "args": {"target": {"label": "Click to edit preset", "index": 0}},
"expect": {"/popup_menu/items": {"empty": false}}},
{"tool": "get_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": "select_objects", "args": {"all": true}},
{"tool": "mouse_gesture", "args": {"action": "click", "button": "right", "at": {"object": 0, "spot": "top"}},
"expect": {"/popup_menu/items": {"contains": "Align/Distribute>Align left (-X)"}}},
{"tool": "mouse_gesture", "args": {"action": "click", "button": "right", "at": {"object": 0, "spot": "top"}},
"expect": {"/popup_menu/items": {"contains": "Delete"}}},
{"tool": "mouse_gesture", "args": {"action": "click", "button": "right", "at": {"object": 0, "spot": "top"}, "popup_item": "Delete"},
"expect": {"/ran": {"eq": "Delete"}}},
{"tool": "get_app_state", "expect": {"/objects": {"eq": 0}, "/closed_menus": {"empty": true}}}
]
}