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>2018-01-04 00:28:19 +0300
committerDalai Felinto <dfelinto@gmail.com>2018-01-04 00:33:00 +0300
commite1cbac715a85204bad48035eb8ee1af79648cd83 (patch)
treee8e17e750ac1c40422cba8de86be3138a72afb0e /tests/python/view_layer
parent10f0635d326e561dfea2675cdd5465ca3b861f24 (diff)
Fix FOREACH_SCENE_COLLECTION/FOREACH_SCENE_OBJECT for nested collections
This fixes any function that relied on these iterators such as: * Outliner Same Type * Metaballs * scene.objects We were not considering the collections when there was collections nested to the collections nested to the master collection. It includes a unittest.
Diffstat (limited to 'tests/python/view_layer')
-rw-r--r--tests/python/view_layer/CMakeLists.txt1
-rw-r--r--tests/python/view_layer/test_scene_objects.py58
2 files changed, 59 insertions, 0 deletions
diff --git a/tests/python/view_layer/CMakeLists.txt b/tests/python/view_layer/CMakeLists.txt
index eaaf25b3889..3f7149a67ad 100644
--- a/tests/python/view_layer/CMakeLists.txt
+++ b/tests/python/view_layer/CMakeLists.txt
@@ -178,5 +178,6 @@ VIEW_LAYER_TEST(scene_copy_d)
VIEW_LAYER_TEST(scene_copy_e)
VIEW_LAYER_TEST(scene_copy_f)
VIEW_LAYER_TEST(scene_delete)
+VIEW_LAYER_TEST(scene_objects)
VIEW_LAYER_TEST(scene_write_read)
VIEW_LAYER_TEST(view_layer_rename)
diff --git a/tests/python/view_layer/test_scene_objects.py b/tests/python/view_layer/test_scene_objects.py
new file mode 100644
index 00000000000..3fae126f206
--- /dev/null
+++ b/tests/python/view_layer/test_scene_objects.py
@@ -0,0 +1,58 @@
+# ############################################################
+# Importing - Same For All Render Layer Tests
+# ############################################################
+
+import unittest
+import os
+import sys
+
+from view_layer_common import *
+
+
+# ############################################################
+# Testing
+# ############################################################
+
+class UnitTesting(ViewLayerTesting):
+ def test_scene_objects_a(self):
+ """
+ Test vanilla scene
+ """
+ import bpy
+
+ scene = bpy.context.scene
+ self.assertEqual(len(scene.objects), 3)
+
+ def test_scene_objects_b(self):
+ """
+ Test scene with nested collections
+ """
+ import bpy
+ scene = bpy.context.scene
+
+ # move default objects to a nested collection
+ master_collection = scene.master_collection
+ collection = master_collection.collections[0]
+ collection_nested = collection.collections.new()
+
+ for ob in collection.objects:
+ collection_nested.objects.link(ob)
+
+ while collection.objects:
+ collection.objects.unlink(collection.objects[0])
+
+ self.assertEqual(len(scene.objects), 3)
+
+
+# ############################################################
+# 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()