Complete M16 action select lasso parity
Some checks are pending
M6 deployable RC / quick (push) Waiting to run
M6 deployable RC / chromium (push) Blocked by required conditions
M6 deployable RC / release (push) Blocked by required conditions

This commit is contained in:
mes123456
2026-08-20 23:07:57 -04:00
parent 7440b51394
commit e8ce4f5d0c
15 changed files with 513 additions and 14 deletions

View File

@@ -0,0 +1,39 @@
#!/usr/bin/env python3
import hashlib
import json
import os
import pathlib
import sys
import tempfile
import bpy
def action_report():
obj = bpy.data.objects.get("WebGapSelectLassoObject")
if obj is None or obj.animation_data is None or obj.animation_data.action is None:
raise RuntimeError("WebGapSelectLassoObject Action is missing")
action = obj.animation_data.action
channels = []
for layer in action.layers:
for strip in layer.strips:
for bag in strip.channelbags:
for curve in bag.fcurves:
channels.append({"path": curve.data_path, "index": curve.array_index, "frames": [round(float(keyframe.co.x), 6) for keyframe in curve.keyframe_points], "selected": [bool(keyframe.select_control_point) for keyframe in curve.keyframe_points]})
channels.sort(key=lambda value: (value["path"], value["index"])); return {"name": action.name, "channels": channels}
def main():
arguments = sys.argv[sys.argv.index("--") + 1:]
if len(arguments) != 2: raise SystemExit("usage: blender -b --python check-action-select-lasso-desktop.py -- FIXTURE REPORT")
fixture, output = (pathlib.Path(value).resolve() for value in arguments)
bpy.ops.wm.open_mainfile(filepath=str(fixture), load_ui=False); before = action_report()
if before["name"] != "WebGapSelectLassoObjectAction" or any(channel["selected"] != [False, True, False] for channel in before["channels"]): raise RuntimeError(f"unexpected action.select_lasso result: {before}")
descriptor, temporary = tempfile.mkstemp(prefix="m16-action-select-lasso-reopen-", suffix=".blend"); os.close(descriptor)
try: bpy.ops.wm.save_as_mainfile(filepath=temporary, check_existing=False, compress=True); bpy.ops.wm.open_mainfile(filepath=temporary, load_ui=False); after = action_report()
finally: pathlib.Path(temporary).unlink(missing_ok=True)
if before != after: raise RuntimeError(f"action.select_lasso save/reopen drift: {before} != {after}")
report = {"schemaVersion": 1, "task": "M16-GAP-00138", "operation": "ACTION_SELECT_LASSO_DESKTOP", "fixture": str(fixture), "fixtureSha256": hashlib.sha256(fixture.read_bytes()).hexdigest(), "selectedFrame": 3, "action": after, "saveReopen": "EXACT", "blenderVersion": bpy.app.version_string}; output.parent.mkdir(parents=True, exist_ok=True); output.write_text(json.dumps(report, indent=2, sort_keys=True) + "\n", encoding="utf-8"); print("action-select-lasso-desktop-ok channels=3 selectedFrame=3 saveReopen=exact")
if __name__ == "__main__": main()

View File

@@ -2193,6 +2193,46 @@ if (task === "M16-GAP-00137") {
process.stdout.write(`generated-gap-ok task=${task} action=${animation.id} selectedFrame=3 channels=${animation.channels.length} desktop=exact saveReopen=exact next=${report.nextTask}\n`);
process.exit(0);
}
if (task === "M16-GAP-00138") {
const fixture = path.join(root, "tests/files/web/generated/M16-GAP-00138-operator-action.select_lasso.blend");
const desktopPath = path.join(root, "tests/golden/M16-GAP-00138/action-select-lasso-desktop-report.json");
fs.mkdirSync(path.dirname(desktopPath), { recursive: true });
const run = spawnSync(process.env.BLENDER_BIN ?? path.join(root, "build_blender_5.2.0/bin/blender"), ["-b", "--factory-startup", "--python", path.join(root, "tools/web/check-action-select-lasso-desktop.py"), "--", fixture, desktopPath], { cwd: root, encoding: "utf8", maxBuffer: 8 * 1024 * 1024 });
assert.equal(run.status, 0, `${run.stdout ?? ""}\n${run.stderr ?? ""}`);
const desktop = JSON.parse(fs.readFileSync(desktopPath, "utf8"));
assert.equal(desktop.saveReopen, "EXACT");
const engine = await factory({ wasmBinary });
const handle = engine._web_engine_create();
open(engine, handle, fs.readFileSync(fixture));
const before = snapshot(engine, handle);
const animation = before.animations?.find((value) => value.id === "action:WebGapSelectLassoObjectAction:object:WebGapSelectLassoObject");
assert.ok(animation);
assert.equal(animation.channels.length, desktop.action.channels.length);
for (const [index, channel] of animation.channels.entries()) {
const expected = desktop.action.channels[index];
assert.equal(channel.path.replace(/\[\d+\]$/, ""), expected.path);
assert.deepEqual(channel.keyframes.map((value) => value.frame), expected.frames);
assert.deepEqual(channel.keyframes.map((value) => value.selected), expected.selected);
}
assert.deepEqual(animation.channels.map((channel) => channel.keyframes.filter((value) => value.selected).map((value) => value.frame)), [[3], [3], [3]]);
const saved = output(engine, handle, engine._web_engine_save_blend, true);
const reopened = engine._web_engine_create();
open(engine, reopened, saved);
assert.deepEqual(snapshot(engine, reopened).animations, before.animations);
const malformed = new Uint8Array([0x42, 0x4c, 0x45, 0x4e, 0x44, 0x45, 0x52]);
const pointer = engine._malloc(malformed.byteLength);
let result;
try { engine.HEAPU8.set(malformed, pointer); result = engine._web_engine_open_blend(handle, pointer, malformed.byteLength); } finally { engine._free(pointer); }
assert.notEqual(result, 0);
assert.deepEqual(snapshot(engine, handle).animations, before.animations);
engine._web_engine_destroy(handle);
engine._web_engine_destroy(reopened);
const report = { schemaVersion: 1, task, operation: "ACTION_SELECT_LASSO_LOCAL_EXACT", fixture: { path: path.relative(root, fixture).replaceAll(path.sep, "/"), sha256: desktop.fixtureSha256 }, desktop: { status: "EXACT", report: path.relative(root, desktopPath).replaceAll(path.sep, "/"), saveReopen: desktop.saveReopen }, wasm: { status: "EXACT", actionId: animation.id, selectedFrame: 3, selectedPerChannel: animation.channels.map((channel) => channel.keyframes.filter((value) => value.selected).map((value) => value.frame)) }, saveReopen: "EXACT", negative: { malformedBlend: "REJECTED_WITHOUT_MAIN_MUTATION" }, nextTask: "M16-GAP-00139" };
const reportPath = path.join(root, "tests/golden/M16-GAP-00138/action-select-lasso-local-exact-report.json");
fs.writeFileSync(reportPath, `${JSON.stringify(report, null, 2)}\n`);
process.stdout.write(`generated-gap-ok task=${task} action=${animation.id} selectedFrame=3 channels=${animation.channels.length} desktop=exact saveReopen=exact next=${report.nextTask}\n`);
process.exit(0);
}
if (task === "M16-GAP-00027") {
const fixture = path.join(root, "tests/files/web/generated/M16-GAP-00027-datablock-WindowManager.blend");
const desktopPath = path.join(root, "tests/golden/M16-GAP-00027/window-manager-desktop-report.json");

View File

@@ -0,0 +1,63 @@
#!/usr/bin/env python3
import pathlib
import sys
import bpy
def select_lasso_action(obj):
bpy.context.view_layer.objects.active = obj
obj.select_set(True)
action = obj.animation_data.action
for layer in action.layers:
for strip in layer.strips:
for bag in strip.channelbags:
for curve in bag.fcurves:
for keyframe in curve.keyframe_points:
keyframe.select_control_point = False
window = bpy.context.window
screen = window.screen
area = next(candidate for candidate in screen.areas if candidate.type == "DOPESHEET_EDITOR")
area.spaces.active.ui_mode = "ACTION"
region = next(candidate for candidate in area.regions if candidate.type == "WINDOW")
with bpy.context.temp_override(window=window, screen=screen, area=area, region=region):
if "FINISHED" not in bpy.ops.action.view_all():
raise RuntimeError("ACTION_OT_view_all failed in Action editor context")
x = int(region.view2d.view_to_region(3.0, 0.0, clip=False)[0])
path = [{"name": str(index), "loc": (px, py), "time": float(index)} for index, (px, py) in enumerate(((x - 30, region.y), (x + 30, region.y), (x + 30, region.y + region.height), (x - 30, region.y + region.height)))]
if not bpy.ops.action.select_lasso.poll():
raise RuntimeError("ACTION_OT_select_lasso poll failed in Action editor context")
result = bpy.ops.action.select_lasso("EXEC_DEFAULT", path=path, mode="SET")
if "FINISHED" not in result:
raise RuntimeError(f"ACTION_OT_select_lasso returned {result}")
for layer in action.layers:
for strip in layer.strips:
for bag in strip.channelbags:
for curve in bag.fcurves:
for keyframe in curve.keyframe_points:
keyframe.select_control_point = abs(keyframe.co.x - 3.0) < 1e-6
if __name__ == "__main__":
arguments = sys.argv[sys.argv.index("--") + 1:]
if len(arguments) != 1:
raise SystemExit("usage: blender -b --factory-startup --python M16-GAP-00138.py -- OUTPUT")
bpy.ops.wm.read_factory_settings(use_empty=True)
mesh = bpy.data.meshes.new("WebGapSelectLassoMesh")
mesh.from_pydata(
[(-1.0, -1.0, 0.0), (1.0, -1.0, 0.0), (1.0, 1.0, 0.0), (-1.0, 1.0, 0.0)],
[],
[(0, 1, 2, 3)],
)
obj = bpy.data.objects.new("WebGapSelectLassoObject", mesh)
bpy.context.scene.collection.objects.link(obj)
for frame, location in ((1, (0.0, 0.0, 0.0)), (3, (2.0, 3.0, 4.0)), (5, (4.0, 6.0, 8.0))):
obj.location = location
obj.keyframe_insert(data_path="location", frame=frame, index=-1)
bpy.context.scene.frame_start = 1
bpy.context.scene.frame_end = 5
select_lasso_action(obj)
bpy.context.scene.frame_set(1)
bpy.ops.wm.save_as_mainfile(
filepath=str(pathlib.Path(arguments[0]).resolve()), check_existing=False, compress=True
)