Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDalai Felinto <dfelinto@gmail.com>2017-02-23 14:35:14 +0300
committerDalai Felinto <dfelinto@gmail.com>2017-02-24 12:10:24 +0300
commit2f9a0dfe6429661f1d4bdf28398504df7fe98beb (patch)
treeb95bf074a6b3f6246b99ebda3a663ed435dda150 /tests/python/render_layer
parent8261a84ffbe6d6a88389f374656135cef53e5b15 (diff)
Fix T50714: Collections: Adding object to scene without an existing collection
This was causing blender to segfault. We now add create a new collection and link to the layer before adding the new object (also included unittests, and requires updated lib/tests)
Diffstat (limited to 'tests/python/render_layer')
-rw-r--r--tests/python/render_layer/CMakeLists.txt3
-rw-r--r--tests/python/render_layer/render_layer_common.py27
-rw-r--r--tests/python/render_layer/test_object_add_no_collection_cylinder.py40
-rw-r--r--tests/python/render_layer/test_object_add_no_collection_empty.py39
-rw-r--r--tests/python/render_layer/test_object_add_no_collection_torus.py39
5 files changed, 148 insertions, 0 deletions
diff --git a/tests/python/render_layer/CMakeLists.txt b/tests/python/render_layer/CMakeLists.txt
index ff98d95cc09..78253268173 100644
--- a/tests/python/render_layer/CMakeLists.txt
+++ b/tests/python/render_layer/CMakeLists.txt
@@ -67,6 +67,9 @@ RENDER_LAYER_TEST(operator_context)
RENDER_LAYER_TEST(object_add_cylinder)
RENDER_LAYER_TEST(object_add_empty)
RENDER_LAYER_TEST(object_add_torus)
+RENDER_LAYER_TEST(object_add_no_collection_cylinder)
+RENDER_LAYER_TEST(object_add_no_collection_empty)
+RENDER_LAYER_TEST(object_add_no_collection_torus)
RENDER_LAYER_TEST(object_copy)
RENDER_LAYER_TEST(evaluation_visibility_a)
RENDER_LAYER_TEST(evaluation_visibility_b)
diff --git a/tests/python/render_layer/render_layer_common.py b/tests/python/render_layer/render_layer_common.py
index e551518ac53..d24b80e0d0a 100644
--- a/tests/python/render_layer/render_layer_common.py
+++ b/tests/python/render_layer/render_layer_common.py
@@ -309,3 +309,30 @@ class RenderLayerTesting(unittest.TestCase):
),
"Scene dump files differ")
+ def do_object_add_no_collection(self, add_mode):
+ """
+ Test for adding objects when no collection
+ exists in render layer
+ """
+ import bpy
+
+ # empty layer of collections
+
+ layer = bpy.context.render_layer
+ while layer.collections:
+ layer.collections.unlink(layer.collections[0])
+
+ # add new objects
+ if add_mode == 'EMPTY':
+ bpy.ops.object.add() # 'Empty'
+
+ elif add_mode == 'CYLINDER':
+ bpy.ops.mesh.primitive_cylinder_add() # 'Cylinder'
+
+ elif add_mode == 'TORUS':
+ bpy.ops.mesh.primitive_torus_add() # 'Torus'
+
+ self.assertEqual(len(layer.collections), 1, "New collection not created")
+ collection = layer.collections[0]
+ self.assertEqual(len(collection.objects), 1, "New collection is empty")
+
diff --git a/tests/python/render_layer/test_object_add_no_collection_cylinder.py b/tests/python/render_layer/test_object_add_no_collection_cylinder.py
new file mode 100644
index 00000000000..72bd046d758
--- /dev/null
+++ b/tests/python/render_layer/test_object_add_no_collection_cylinder.py
@@ -0,0 +1,40 @@
+# ./blender.bin --background -noaudio --python tests/python/render_layer/test_scene_copy.py -- --testdir="/data/lib/tests/"
+
+# ############################################################
+# Importing - Same For All Render Layer Tests
+# ############################################################
+
+import unittest
+
+import os, sys
+sys.path.append(os.path.dirname(__file__))
+
+from render_layer_common import *
+
+
+# ############################################################
+# Testing
+# ############################################################
+
+class UnitTesting(RenderLayerTesting):
+ def test_object_add_cylinder(self):
+ """
+ See if new objects are added to the correct collection
+ bpy.ops.mesh.primitive_cylinder_add()
+ """
+ import os
+ self.do_object_add_no_collection('CYLINDER')
+
+
+# ############################################################
+# Main - Same For All Render Layer Tests
+# ############################################################
+
+if __name__ == '__main__':
+ import sys
+
+ extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
+ sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else [])
+
+ UnitTesting._extra_arguments = extra_arguments
+ unittest.main()
diff --git a/tests/python/render_layer/test_object_add_no_collection_empty.py b/tests/python/render_layer/test_object_add_no_collection_empty.py
new file mode 100644
index 00000000000..49600f2e73e
--- /dev/null
+++ b/tests/python/render_layer/test_object_add_no_collection_empty.py
@@ -0,0 +1,39 @@
+# ./blender.bin --background -noaudio --python tests/python/render_layer/test_scene_copy.py -- --testdir="/data/lib/tests/"
+
+# ############################################################
+# Importing - Same For All Render Layer Tests
+# ############################################################
+
+import unittest
+
+import os, sys
+sys.path.append(os.path.dirname(__file__))
+
+from render_layer_common import *
+
+
+# ############################################################
+# Testing
+# ############################################################
+
+class UnitTesting(RenderLayerTesting):
+ def test_syncing_object_add_empty(self):
+ """
+ See if new objects are added to the correct collection
+ bpy.ops.object.add()
+ """
+ self.do_object_add_no_collection('EMPTY')
+
+
+# ############################################################
+# Main - Same For All Render Layer Tests
+# ############################################################
+
+if __name__ == '__main__':
+ import sys
+
+ extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
+ sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else [])
+
+ UnitTesting._extra_arguments = extra_arguments
+ unittest.main()
diff --git a/tests/python/render_layer/test_object_add_no_collection_torus.py b/tests/python/render_layer/test_object_add_no_collection_torus.py
new file mode 100644
index 00000000000..11358d680a1
--- /dev/null
+++ b/tests/python/render_layer/test_object_add_no_collection_torus.py
@@ -0,0 +1,39 @@
+# ./blender.bin --background -noaudio --python tests/python/render_layer/test_scene_copy.py -- --testdir="/data/lib/tests/"
+
+# ############################################################
+# Importing - Same For All Render Layer Tests
+# ############################################################
+
+import unittest
+
+import os, sys
+sys.path.append(os.path.dirname(__file__))
+
+from render_layer_common import *
+
+
+# ############################################################
+# Testing
+# ############################################################
+
+class UnitTesting(RenderLayerTesting):
+ def test_syncing_object_add_torus(self):
+ """
+ See if new objects are added to the correct collection
+ bpy.ops.mesh.primitive_torus_add()
+ """
+ self.do_object_add_no_collection('TORUS')
+
+
+# ############################################################
+# Main - Same For All Render Layer Tests
+# ############################################################
+
+if __name__ == '__main__':
+ import sys
+
+ extra_arguments = sys.argv[sys.argv.index("--") + 1:] if "--" in sys.argv else []
+ sys.argv = [__file__] + (sys.argv[sys.argv.index("--") + 2:] if "--" in sys.argv else [])
+
+ UnitTesting._extra_arguments = extra_arguments
+ unittest.main()