diff --git a/tests/files/sculpting/apply_base_monkey.blend b/tests/files/sculpting/apply_base_monkey.blend new file mode 100644 index 00000000000..c6f01375cb6 --- /dev/null +++ b/tests/files/sculpting/apply_base_monkey.blend @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0841ba09547253dc309234056295bbf27d9ff752f6abb0ea8600cc1e46647a7f +size 310297 diff --git a/tests/python/CMakeLists.txt b/tests/python/CMakeLists.txt index b95a9189ab7..f25e662c53c 100644 --- a/tests/python/CMakeLists.txt +++ b/tests/python/CMakeLists.txt @@ -493,6 +493,13 @@ if(TEST_SRC_DIR_EXISTS) -- --testdir "${TEST_SRC_DIR}/constraints" ) + + add_blender_test( + multires + --python ${TEST_PYTHON_DIR}/bl_multires.py + -- + --testdir "${TEST_SRC_DIR}/sculpting" + ) endif() # ------------------------------------------------------------------------------ diff --git a/tests/python/bl_multires.py b/tests/python/bl_multires.py new file mode 100644 index 00000000000..36d3a40384f --- /dev/null +++ b/tests/python/bl_multires.py @@ -0,0 +1,58 @@ +# SPDX-FileCopyrightText: 2025 Blender Authors +# +# SPDX-License-Identifier: GPL-2.0-or-later */ + +__all__ = ( + "main", +) + +import unittest +import sys +import pathlib + +import bpy +from mathutils import Vector + +""" +blender -b --factory-startup --python tests/python/bl_object_modifier_multires.py -- --testdir tests/files/sculpting/ +""" + +args = None + + +class ApplyBase(unittest.TestCase): + def setUp(self): + bpy.ops.wm.open_mainfile(filepath=str(args.testdir / "apply_base_monkey.blend"), load_ui=False) + + def test_subdividing_cube_results_in_same_mesh(self): + bpy.ops.mesh.primitive_monkey_add() + new_cube = bpy.context.object + + multires_mod = new_cube.modifiers.new("Multires", 'MULTIRES') + bpy.ops.object.multires_subdivide(modifier="Multires") + bpy.ops.object.multires_base_apply(modifier="Multires") + bpy.ops.object.modifier_remove(modifier="Multires") + + expected_mesh = bpy.data.objects['Expected_Base_Mesh'] + result = expected_mesh.data.unit_test_compare(mesh=new_cube.data) + self.assertEqual(result, 'Same') + + +def main(): + global args + import argparse + + argv = [sys.argv[0]] + if '--' in sys.argv: + argv += sys.argv[sys.argv.index('--') + 1:] + + parser = argparse.ArgumentParser() + parser.add_argument('--testdir', required=True, type=pathlib.Path) + + args, remaining = parser.parse_known_args(argv) + + unittest.main(argv=remaining) + + +if __name__ == '__main__': + main()