Add comprehensive tests for edge depth extension, empty image edits, and material view adaptation

- Introduced `test_edge_depth.py` to validate the functionality of edge depth extension, ensuring core alpha preservation, proper depth handling, and edge padding behavior.
- Created `test_empty_image_edits.py` to verify the behavior of image edits in Blender, focusing on shared edits, preservation of image properties, and handling of failed operations.
- Developed `test_material_view_adaptation.py` to test material adaptation preferences, ensuring color space and alpha settings are correctly applied and preserved across various scenarios.
This commit is contained in:
2026-09-06 21:43:47 +08:00
parent 1994d38ccd
commit 7e55af6722
58 changed files with 3607 additions and 200 deletions

View File

@@ -37,11 +37,15 @@ def cutout_context(
mesh_detail="LOW",
generate_normal=False,
inward_axis="NEGATIVE_Z",
alpha_threshold=0.9,
fine_outline=True,
):
settings = SimpleNamespace(
cutout_mesh_detail=mesh_detail,
cutout_generate_normal=generate_normal,
cutout_inward_axis=inward_axis,
cutout_alpha_threshold=alpha_threshold,
cutout_fine_outline=fine_outline,
)
return SimpleNamespace(
window_manager=window_manager,
@@ -49,6 +53,21 @@ def cutout_context(
)
def test_cutout_menu_captures_fine_outline_before_later_redraw(monkeypatch):
window_manager = WindowManager()
context = cutout_context(window_manager)
monkeypatch.setattr(interaction, "ai_ready", lambda: False)
def delayed_popup(_event, draw, **_options):
context.scene.anyimage_settings.cutout_fine_outline = False
draw(SimpleNamespace(layout=SimpleNamespace(menu_pie=lambda: window_manager.pie)), None)
window_manager.popup_menu_pie = delayed_popup
interaction.open_shape_pie(context, object(), cutout_source(),
SelectionPath(points=((0, 0), (10, 0), (0, 10))))
assert all(call[2].fine_outline is True for call in window_manager.pie.calls)
def cutout_source(name="Source", size=(2048, 1024)):
return SimpleNamespace(name=name, data=SimpleNamespace(size=size))
@@ -90,6 +109,8 @@ def test_cutout_pie_passes_image_lasso_options_to_all_ai_shapes(monkeypatch):
mesh_detail="MEDIUM",
generate_normal=True,
inward_axis="POSITIVE_X",
alpha_threshold=0.1,
fine_outline=False,
)
source = cutout_source(size=(4096, 2048))
monkeypatch.setattr(interaction, "ai_ready", lambda: True)
@@ -119,6 +140,8 @@ def test_cutout_pie_passes_image_lasso_options_to_all_ai_shapes(monkeypatch):
"DEPTH_SURFACE",
]
assert all(call[2].generate_normal for call in window_manager.pie.calls)
assert all(call[2].alpha_threshold == 0.1 for call in window_manager.pie.calls)
assert all(call[2].fine_outline is False for call in window_manager.pie.calls)
assert len(serialized) == 1
assert set(json.loads(serialized[0])) == {"points"}
assert all(