Open every MCP test instance at 1600x900 in the top left of the screen

This commit is contained in:
SoftFever committed 2026-11-15 15:51:58 +08:00
1 parent 241240f844
commit 5698fe1f7e
32 files changed
+74 -37

No files matched your search

+4 -1
View File
@@ -20,7 +20,10 @@ an `OrcaSlicer.conf` that has a finished setup wizard and one printer and filame
Carbon 0.4 by default), with update checks and daily tips turned off, and with the Orca Cloud login kept
in a token file in the datadir (`use_encrypted_token_file`) instead of the system's secret store, so the
instance starts signed out and never reads your login: on macOS that read would stop a newly built app at
a keychain prompt. `--cad` starts the app with
a keychain prompt. A seeded datadir's main window opens 1600×900 at the top left of the screen's work area
(on macOS below the menu bar), so it fits on a 1920×1080 screen, instances started side by side stay on
screen, and the tests' views and screenshots all have one size; the tests that size the window ask for
the same 1600×900. `--cad` starts the app with
`--cad`, which turns the Design (CAD) tab on for that run, and with it its commands, and
`--unrestricted-scripts` starts it with `--unrestricted-scripts`, which lets Python scripts
(`run_script`) run unrestricted for that run. Neither writes the datadir's `OrcaSlicer.conf`, and a later
+29 -2
View File
@@ -46,6 +46,10 @@ PROTOCOL = "2025-11-25"
# A finished setup with one printer, so a fresh datadir opens straight into the main window.
DEFAULT_PRINTER = ("BBL", "Bambu Lab X1 Carbon", "0.4", "Bambu PLA Basic @BBL X1C")
# A fresh datadir's main window: at the top left of the screen's work area, small enough for a 1920 x 1080
# screen to show all of it, so instances started side by side stay on screen and a view or screenshot taken in
# one has the same size in another.
WINDOW_SIZE = (1600, 900)
def reply_budget_s():
@@ -276,22 +280,45 @@ def write_conf(conf, data):
f.write("\n")
def work_area_origin():
"""The top-left corner of the main display's work area, the part windows may cover: on macOS below the
menu bar and right of a Dock on the left, read from AppKit; (0, 0) where that cannot be read and on the
other systems, whose taskbar or panel usually sits at the bottom, and whose private displays have none."""
if sys.platform != "darwin":
return 0, 0
# AppKit measures from the bottom left; the first screen is the one with the menu bar.
script = ('ObjC.import("AppKit"); var s = $.NSScreen.screens.objectAtIndex(0), f = s.frame, v = s.visibleFrame;'
'JSON.stringify([v.origin.x - f.origin.x, f.origin.y + f.size.height - v.origin.y - v.size.height])')
try:
out = subprocess.run(["osascript", "-l", "JavaScript", "-e", script], capture_output=True, text=True,
timeout=10).stdout
x, y = json.loads(out)
return round(x), round(y)
except (OSError, subprocess.SubprocessError, ValueError, TypeError):
return 0, 0
def seed_datadir(datadir, printer):
"""Seed a fresh datadir's OrcaSlicer.conf. A datadir that has one keeps it.
A fresh datadir keeps the Orca Cloud login in its own token file (use_encrypted_token_file), not in the
system's secret store, so the instance starts signed out and never reads the person's login: on macOS
that read stops a newly built app at a keychain prompt that only a person can answer."""
that read stops a newly built app at a keychain prompt that only a person can answer. Its main window
opens WINDOW_SIZE at the top left of the work area: the app trims a saved window to the work area, so one
placed over the macOS menu bar would open that much shorter."""
vendor, model, nozzle, filament = printer
os.makedirs(datadir, exist_ok=True)
conf = os.path.join(datadir, "OrcaSlicer.conf")
if os.path.exists(conf):
return
x, y = work_area_origin()
width, height = WINDOW_SIZE
write_conf(conf, {"firstguide": {"finish": True},
"models": [{"model": model, "nozzle_diameter": nozzle, "vendor": vendor}],
"filaments": [filament],
"presets": {"machine": f"{model} {nozzle} nozzle"},
"app": {"check_for_updates": False, "show_daily_tips": False, "use_encrypted_token_file": True}})
"app": {"check_for_updates": False, "show_daily_tips": False, "use_encrypted_token_file": True,
"window_mainframe": f"{x}; {y}; {width}; {height}; 0"}})
# The headless compositors --headless tries, in order, by the binary each needs.
+9 -2
View File
@@ -12,7 +12,8 @@ mcp/server.json, or whose server.json is not JSON or names no port, naming the f
answers (HTTP 401, a reply that is not JSON), also chaining the cause. call_command(), against a
stubbed call(), fails at once on a dialog, follows a running job, prefixes its errors with the
command's name, chaining the original, and returns the command's whole reply. seed_datadir() keeps a fresh
datadir's login in its own token file and leaves a reused datadir's where it is. ORCA_MCP_CALL_LOG gets a line
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.
"""
@@ -284,10 +285,16 @@ def read_conf(datadir):
def check_seed_datadir():
fresh = scratch("orca-seed-")
orca_mcp.seed_datadir(fresh, orca_mcp.DEFAULT_PRINTER)
with mock.patch.object(orca_mcp, "work_area_origin", return_value=(12, 34)):
orca_mcp.seed_datadir(fresh, orca_mcp.DEFAULT_PRINTER)
app = read_conf(fresh)["app"]
assert app.get("use_encrypted_token_file") is True, app
ok("seed_datadir() keeps a fresh datadir's login in its own token file, not the system's secret store")
assert orca_mcp.WINDOW_SIZE == (1600, 900), orca_mcp.WINDOW_SIZE
assert app.get("window_mainframe") == "12; 34; 1600; 900; 0", app
x, y = orca_mcp.work_area_origin()
assert isinstance(x, int) and isinstance(y, int) and x >= 0 and y >= 0, (x, y)
ok("seed_datadir() opens a fresh datadir's main window 1600 x 900 at the top left of the work area")
reused = scratch("orca-seed-reused-")
orca_mcp.write_conf(os.path.join(reused, "OrcaSlicer.conf"), {"app": {"use_encrypted_token_file": False}})
+3 -3
View File
@@ -46,7 +46,7 @@ def main():
def close(a, b, tolerance):
return isinstance(a, (int, float)) and abs(a - b) <= tolerance
client.call("set_window", size=[1920, 1200])
client.call("set_window", size=[1600, 900])
client.call("new_project", discard_changes=True)
# 1. Prepare, straight after new_project: the fit it queued runs first, then look_at and zoom.
@@ -141,13 +141,13 @@ def main():
# 9. A fit after the window was sized on the Home tab, where no 3D view draws, fits the canvas's new size:
# the same fit straight after keeps its zoom.
set_view(tab="home")
client.call("set_window", size=[1600, 1000])
client.call("set_window", size=[1400, 800])
first = set_view(tab="prepare", camera="fit_objects")
second = set_view(camera="fit_objects")
zoom = first.get("camera_state", {}).get("zoom")
check("resized on home: a fit on prepare uses the new size",
zoom is not None and close(second.get("camera_state", {}).get("zoom"), zoom, 1e-3), (first, second))
client.call("set_window", size=[1920, 1200])
client.call("set_window", size=[1600, 900])
# 10. On a tab with no 3D view, the fit new_project queues waits for the view to draw: get_app_state has no
# camera, a zoom given then is applied with a note that the fit is still queued, and the fit replaces it
+2 -2
View File
@@ -288,8 +288,8 @@ def main():
flat = client.call("set_window", width=1500, height=950)
check("flat form: width and height are read as size", flat.get("size") == [1500, 950], flat)
# 12. Clean-up.
client.call("set_window", size=[1920, 1200])
# 12. Clean-up: the size a fresh launch gives.
client.call("set_window", size=list(orca_mcp.WINDOW_SIZE))
failed = [c for c in checks if not c[1]]
for name, ok, detail in checks:
+1 -1
View File
@@ -15,7 +15,7 @@
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "call_tool", "args": {"tool": "new_design", "args": {"discard_changes": true}}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "design", "camera": "iso"},
"expect": {"/tab": {"eq": "design"}, "/camera": {"eq": "iso"}}},
{"tool": "call_tool", "args": {"tool": "extrude", "args": {"width": 20, "height": 20, "distance": 10}},
+1 -1
View File
@@ -15,7 +15,7 @@
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "call_tool", "args": {"tool": "new_design"}, "expect": {"/result/ok": {"eq": true}, "/result/cleared/features": {"eq": 0}}},
{"tool": "search_tools", "args": {"tool": "describe_feature"}, "expect": {"/group": {"eq": "Design"}, "/read_only": {"eq": true}}},
{"tool": "search_tools", "args": {"tool": "set_feature"}, "expect": {"/group": {"eq": "Design"}, "/read_only": {"eq": false}}},
+1 -1
View File
@@ -12,7 +12,7 @@
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "call_tool", "args": {"tool": "new_design", "args": {"discard_changes": true}}},
// M5 hex standoff: 8 mm across flats, 15 long, M5's 4.134 mm tap drill through it.
+1 -1
View File
@@ -12,7 +12,7 @@
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "call_tool", "args": {"tool": "new_design", "args": {"discard_changes": true}}},
// The bench's M5 hex standoff from a polygon 8 across the flats and its 4.134 mm tap drill.
+1 -1
View File
@@ -11,7 +11,7 @@
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "call_tool", "args": {"tool": "new_design", "args": {"discard_changes": true}}},
// An L-bracket profile on XZ, which passes through modeling_origin, not the bed corner: 40 x 30, 4 thick.
+1 -1
View File
@@ -13,7 +13,7 @@
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "call_tool", "args": {"tool": "new_design", "args": {"discard_changes": true}}},
// Back plate 60 x 5, arm 35 out, lip 15 up, 20 wide.
+1 -1
View File
@@ -14,7 +14,7 @@
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "auto_answer_dialogs", "args": {"rules": [{"match": "restore", "button": "no"}]}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "run_action", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
{"tool": "run_action", "args": {"id": "orca_command:filament_delete:orca"}, "optional": true},
+1 -1
View File
@@ -13,7 +13,7 @@
{"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_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca"}},
{"tool": "wait", "args": {"for": "idle"}},
+1 -1
View File
@@ -15,7 +15,7 @@
{"match": "unsaved changes", "button": "no"},
{"match": "Transfer or discard", "button": "Transfer"}]}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
// ---- An auto-answered Transfer keeps the edit on the newly selected process preset ----
+1 -1
View File
@@ -9,7 +9,7 @@
"orca_replay": 1,
"name": "every gizmo",
"vars": {
"window_size": [1920, 1200],
"window_size": [1600, 900],
"svg": "${replay_dir}/fixtures/star.svg",
"heightmap": "${replay_dir}/fixtures/heightmap.png"
},
+1 -1
View File
@@ -13,7 +13,7 @@
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "open_files", "args": {"paths": ["${vars.cube}"]}, "expect": {"/added": {"eq": 1}}},
{"tool": "transform", "args": {"object": 0, "size": [20, 20, 20]}},
+1 -1
View File
@@ -11,7 +11,7 @@
{"match": "restore", "button": "no"},
{"match": "Uniform scale", "button": "ok"}]}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
// A second filament (or one more, on a datadir an earlier run left with several).
{"tool": "click", "args": {"target": {"label": "Add one filament"}}},
@@ -17,7 +17,7 @@
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_window", "args": {"size": [1920, 1040]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
// Simple mode, as on a fresh datadir: the unsaved-changes prompt lists the settings the mode shows.
{"tool": "run_action", "args": {"id": "orca_command:mode_simple:orca"}},
@@ -14,7 +14,7 @@
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_window", "args": {"size": [1920, 1040]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
// Simple mode, as on a fresh datadir: the unsaved-changes prompt lists the settings the mode shows.
{"tool": "run_action", "args": {"id": "orca_command:mode_simple:orca"}},
+1 -1
View File
@@ -13,7 +13,7 @@
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_window", "args": {"size": [1920, 1040]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
// Simple mode, as on a fresh datadir: the unsaved-changes prompt lists the settings the mode shows.
{"tool": "run_action", "args": {"id": "orca_command:mode_simple:orca"}},
+1 -1
View File
@@ -12,7 +12,7 @@
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_window", "args": {"size": [1600, 1000]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "args": {"size": [20, 20, 20]}}},
{"tool": "wait", "args": {"for": "idle"}},
+1 -1
View File
@@ -12,7 +12,7 @@
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_window", "args": {"size": [1600, 1000]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca", "args": {"size": [20, 20, 20]}}},
{"tool": "run_action", "args": {"id": "orca_command:plate_add:orca"}},
+1 -1
View File
@@ -12,7 +12,7 @@
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_window", "args": {"size": [1600, 1000]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "wait", "args": {"for": "idle"}},
{"tool": "run_script", "args": {"filename": "${vars.undo}", "code": "import ops_undo\nresult = ops_undo.taken()"}},
+1 -1
View File
@@ -13,7 +13,7 @@
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "auto_answer_dialogs", "args": {"rules": [{"match": "Uniform scale", "button": "ok"}]}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "list_widgets", "args": {"target": "main", "query": "plate_icon"}, "expect": {"/nodes": {"ge": 7}}},
+1 -1
View File
@@ -17,7 +17,7 @@
{"match": "Uniform scale", "button": "ok"},
{"match": "Spiral mode only works", "button": "yes"}]}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
// ---- Filament slots: down to one with the - button's command, then a second ----
+1 -1
View File
@@ -20,7 +20,7 @@
{"tool": "auto_answer_dialogs", "args": {"rules": [{"match": "restore", "button": "no"}, {"match": "Uniform scale", "button": "ok"}]}},
// Unsaved edits a person (or an earlier run) left are dropped first, so nothing below asks about them.
{"tool": "new_project", "args": {"discard_changes": true, "preset_changes": "discard"}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
// The unsaved-changes prompt lists only the settings the mode shows, and Simple mode also turns
// Developer mode off, which the detach refusal below needs.
{"tool": "run_action", "args": {"id": "orca_command:mode_simple:orca"}},
+1 -1
View File
@@ -16,7 +16,7 @@
{"tool": "auto_answer_dialogs", "args": {"rules": [{"match": "Uniform scale", "button": "ok"},
{"match": "unsaved changes. Would you like to save", "button": "No"}]}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca"}},
{"tool": "wait", "args": {"for": "idle"}},
+1 -1
View File
@@ -12,7 +12,7 @@
{"tool": "auto_answer_dialogs", "args": {"rules": [{"match": "unsaved changes", "button": "no"},
{"match": "restore", "button": "no"}]}},
{"tool": "new_project", "args": {"silent": true}},
{"tool": "set_window", "args": {"size": [1600, 1000]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "start_recording", "args": {"save_path": "${out_dir}/session.mkv", "overwrite": true, "captions": true,
"pointer": true},
+1 -1
View File
@@ -14,7 +14,7 @@
{"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_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "run_action", "args": {"id": "orca_command:add_primitive_cube:orca"}},
{"tool": "wait", "args": {"for": "idle"}},
+1 -1
View File
@@ -13,7 +13,7 @@
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
// ---- An instance: a scale that grows it drops it onto the bed; size keeps the proportions ----
+1 -1
View File
@@ -12,7 +12,7 @@
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "auto_answer_dialogs", "args": {"rules": [{"match": "Uniform scale", "button": "ok"}]}},
{"tool": "new_project", "args": {"discard_changes": true}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
{"tool": "click", "args": {"target": {"label": "Add one filament"}}},
{"tool": "get_app_state", "expect": {"/presets/filaments/1": {"exists": true}}},
+1 -1
View File
@@ -10,7 +10,7 @@
"name": "web dialogs through the GUI tools",
"steps": [
{"tool": "wait", "args": {"for": "ready"}},
{"tool": "set_window", "args": {"size": [1920, 1200]}},
{"tool": "set_window", "args": {"size": [1600, 900]}},
{"tool": "set_view", "args": {"tab": "prepare"}},
// ---- The preset bundle dialog, closed by its page's own button ----