mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Extend node group tests to cover change of subtype and dimensions
Extend node group tests to cover change of subtype and dimensions The node group interface tests did not include changes to socket subtypes and/or vector dimension details. These settings affect the RNA struct type of the socket and the size of default value arrays. The change of subtype details has the unfortunate effect of invalidating any existing python object representing the interface socket or node socket. This isn't easy to fix, but the test now covers this expected behavior. Pull Request: https://projects.blender.org/blender/blender/pulls/153254
This commit is contained in:
parent
895cf27696
commit
6ad681ce05
1 changed files with 51 additions and 1 deletions
|
|
@ -145,7 +145,7 @@ class NodeGroupInterfaceTests:
|
|||
expected_users,
|
||||
f"Socket default value has user count {value.users}, expected {expected_users}")
|
||||
|
||||
def do_test_socket_type(self, socket_type):
|
||||
def do_test_socket_type(self, socket_type, subtype=None, dimensions=None):
|
||||
default_value = self.make_default_socket_value(socket_type)
|
||||
compare_value = self.make_socket_value_comparator(socket_type)
|
||||
|
||||
|
|
@ -159,6 +159,35 @@ class NodeGroupInterfaceTests:
|
|||
out0 = tree.interface.new_socket("Output 0", socket_type=socket_type, in_out='OUTPUT')
|
||||
self.assertIsNotNone(in0, f"Could not create socket of type {socket_type}")
|
||||
self.assertIsNotNone(out0, f"Could not create socket of type {socket_type}")
|
||||
# Note: the type of the socket python object remains the same even when
|
||||
# the actual type of the socket in the tree changes due to changing the
|
||||
# subtype and/or dimensions! It would be nice if that can be avoided in
|
||||
# the future, but for now is expected behavior.
|
||||
in0_old_suffix = in0.bl_socket_idname.removeprefix("Node")
|
||||
out0_old_suffix = out0.bl_socket_idname.removeprefix("Node")
|
||||
expect_same_idname = True
|
||||
if subtype is not None:
|
||||
if subtype != in0.subtype:
|
||||
expect_same_idname = False
|
||||
in0.subtype = subtype
|
||||
out0.subtype = subtype
|
||||
if dimensions is not None:
|
||||
if dimensions != in0.dimensions:
|
||||
expect_same_idname = False
|
||||
in0.dimensions = dimensions
|
||||
out0.dimensions = dimensions
|
||||
|
||||
self.assertEqual(type(in0).__name__.removeprefix("NodeTreeInterface"), in0_old_suffix)
|
||||
self.assertEqual(type(out0).__name__.removeprefix("NodeTreeInterface"), out0_old_suffix)
|
||||
# Get the sockets from the tree again to use the correct the type.
|
||||
in0 = tree.interface.items_tree[in0.identifier]
|
||||
out0 = tree.interface.items_tree[out0.identifier]
|
||||
if expect_same_idname:
|
||||
self.assertEqual(type(in0).__name__.removeprefix("NodeTreeInterface"), in0_old_suffix)
|
||||
self.assertEqual(type(out0).__name__.removeprefix("NodeTreeInterface"), out0_old_suffix)
|
||||
else:
|
||||
self.assertNotEqual(type(in0).__name__.removeprefix("NodeTreeInterface"), in0_old_suffix)
|
||||
self.assertNotEqual(type(out0).__name__.removeprefix("NodeTreeInterface"), out0_old_suffix)
|
||||
|
||||
# Now make a node group instance to check default values.
|
||||
group_node = self.make_instance(tree)
|
||||
|
|
@ -349,9 +378,11 @@ class GeometryNodeGroupInterfaceTest(AbstractNodeGroupInterfaceTest, NodeGroupIn
|
|||
self.do_test_socket_type("NodeSocketCollection")
|
||||
self.do_test_socket_type("NodeSocketColor")
|
||||
self.do_test_socket_type("NodeSocketFloat")
|
||||
self.do_test_socket_type("NodeSocketFloat", subtype='FACTOR')
|
||||
self.do_test_socket_type("NodeSocketGeometry")
|
||||
self.do_test_socket_type("NodeSocketImage")
|
||||
self.do_test_socket_type("NodeSocketInt")
|
||||
self.do_test_socket_type("NodeSocketInt", subtype='PERCENTAGE')
|
||||
self.do_test_socket_type("NodeSocketMaterial")
|
||||
self.do_test_socket_type("NodeSocketObject")
|
||||
self.do_test_socket_type("NodeSocketRotation")
|
||||
|
|
@ -359,6 +390,11 @@ class GeometryNodeGroupInterfaceTest(AbstractNodeGroupInterfaceTest, NodeGroupIn
|
|||
self.do_test_socket_type("NodeSocketString")
|
||||
self.do_test_invalid_socket_type("NodeSocketTexture")
|
||||
self.do_test_socket_type("NodeSocketVector")
|
||||
self.do_test_socket_type("NodeSocketVector", dimensions=2)
|
||||
self.do_test_socket_type("NodeSocketVector", dimensions=4)
|
||||
self.do_test_socket_type("NodeSocketVector", subtype='TRANSLATION')
|
||||
self.do_test_socket_type("NodeSocketVector", subtype='TRANSLATION', dimensions=2)
|
||||
self.do_test_socket_type("NodeSocketVector", subtype='TRANSLATION', dimensions=4)
|
||||
self.do_test_invalid_socket_type("NodeSocketVirtual")
|
||||
|
||||
def test_items_order_classic(self):
|
||||
|
|
@ -394,9 +430,11 @@ class ShaderNodeGroupInterfaceTest(AbstractNodeGroupInterfaceTest, NodeGroupInte
|
|||
self.do_test_invalid_socket_type("NodeSocketCollection")
|
||||
self.do_test_socket_type("NodeSocketColor")
|
||||
self.do_test_socket_type("NodeSocketFloat")
|
||||
self.do_test_socket_type("NodeSocketFloat", subtype='FACTOR')
|
||||
self.do_test_invalid_socket_type("NodeSocketGeometry")
|
||||
self.do_test_invalid_socket_type("NodeSocketImage")
|
||||
self.do_test_socket_type("NodeSocketInt")
|
||||
self.do_test_socket_type("NodeSocketInt", subtype='PERCENTAGE')
|
||||
self.do_test_invalid_socket_type("NodeSocketMaterial")
|
||||
self.do_test_invalid_socket_type("NodeSocketObject")
|
||||
self.do_test_invalid_socket_type("NodeSocketRotation")
|
||||
|
|
@ -404,6 +442,11 @@ class ShaderNodeGroupInterfaceTest(AbstractNodeGroupInterfaceTest, NodeGroupInte
|
|||
self.do_test_invalid_socket_type("NodeSocketString")
|
||||
self.do_test_invalid_socket_type("NodeSocketTexture")
|
||||
self.do_test_socket_type("NodeSocketVector")
|
||||
self.do_test_socket_type("NodeSocketVector", dimensions=2)
|
||||
self.do_test_socket_type("NodeSocketVector", dimensions=4)
|
||||
self.do_test_socket_type("NodeSocketVector", subtype='TRANSLATION')
|
||||
self.do_test_socket_type("NodeSocketVector", subtype='TRANSLATION', dimensions=2)
|
||||
self.do_test_socket_type("NodeSocketVector", subtype='TRANSLATION', dimensions=4)
|
||||
self.do_test_invalid_socket_type("NodeSocketVirtual")
|
||||
|
||||
def test_items_order_classic(self):
|
||||
|
|
@ -440,9 +483,11 @@ class CompositorNodeGroupInterfaceTest(AbstractNodeGroupInterfaceTest, NodeGroup
|
|||
self.do_test_invalid_socket_type("NodeSocketCollection")
|
||||
self.do_test_socket_type("NodeSocketColor")
|
||||
self.do_test_socket_type("NodeSocketFloat")
|
||||
self.do_test_socket_type("NodeSocketFloat", subtype='FACTOR')
|
||||
self.do_test_invalid_socket_type("NodeSocketGeometry")
|
||||
self.do_test_invalid_socket_type("NodeSocketImage")
|
||||
self.do_test_socket_type("NodeSocketInt")
|
||||
self.do_test_socket_type("NodeSocketInt", subtype='PERCENTAGE')
|
||||
self.do_test_invalid_socket_type("NodeSocketMaterial")
|
||||
self.do_test_invalid_socket_type("NodeSocketObject")
|
||||
self.do_test_invalid_socket_type("NodeSocketRotation")
|
||||
|
|
@ -450,6 +495,11 @@ class CompositorNodeGroupInterfaceTest(AbstractNodeGroupInterfaceTest, NodeGroup
|
|||
self.do_test_socket_type("NodeSocketString")
|
||||
self.do_test_invalid_socket_type("NodeSocketTexture")
|
||||
self.do_test_socket_type("NodeSocketVector")
|
||||
self.do_test_socket_type("NodeSocketVector", dimensions=2)
|
||||
self.do_test_socket_type("NodeSocketVector", dimensions=4)
|
||||
self.do_test_socket_type("NodeSocketVector", subtype='TRANSLATION')
|
||||
self.do_test_socket_type("NodeSocketVector", subtype='TRANSLATION', dimensions=2)
|
||||
self.do_test_socket_type("NodeSocketVector", subtype='TRANSLATION', dimensions=4)
|
||||
self.do_test_invalid_socket_type("NodeSocketVirtual")
|
||||
|
||||
def test_items_order_classic(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue