[Bf-blender-cvs] [1971dd29768] blender2.8: Layers Unittest: Background set

Dalai Felinto noreply at git.blender.org
Fri Nov 24 13:54:30 CET 2017


Commit: 1971dd2976886a87a849510a642247579e663c5e
Author: Dalai Felinto
Date:   Fri Nov 24 10:54:13 2017 -0200
Branches: blender2.8
https://developer.blender.org/rB1971dd2976886a87a849510a642247579e663c5e

Layers Unittest: Background set

This is an incomplete test since we cannot check for the
depsgraph selection value with the current API, nor can we
see if the relationship lines are being drawn.

===================================================================

M	tests/python/view_layer/CMakeLists.txt
A	tests/python/view_layer/test_background_set.py

===================================================================

diff --git a/tests/python/view_layer/CMakeLists.txt b/tests/python/view_layer/CMakeLists.txt
index 48206f61db4..e5b271dcb1e 100644
--- a/tests/python/view_layer/CMakeLists.txt
+++ b/tests/python/view_layer/CMakeLists.txt
@@ -61,6 +61,7 @@ macro(VIEW_LAYER_TEST test_name)
 endmacro()
 
 VIEW_LAYER_TEST(active_collection)
+VIEW_LAYER_TEST(background_set)
 VIEW_LAYER_TEST(collection_rename)
 VIEW_LAYER_TEST(evaluation_render_settings_a)
 VIEW_LAYER_TEST(evaluation_render_settings_b)
diff --git a/tests/python/view_layer/test_background_set.py b/tests/python/view_layer/test_background_set.py
new file mode 100644
index 00000000000..a227d4d189c
--- /dev/null
+++ b/tests/python/view_layer/test_background_set.py
@@ -0,0 +1,69 @@
+# ############################################################
+# Importing - Same For All Render Layer Tests
+# ############################################################
+
+import unittest
+import os
+import sys
+
+from view_layer_common import *
+
+
+# ############################################################
+# Testing
+# ############################################################
+
+class UnitTesting(ViewLayerTesting):
+    def test_background_set(self):
+        """
+        See if background sets are properly added and removed
+        """
+        import bpy
+
+        background_scene = bpy.data.scenes[0]
+        main_scene = bpy.data.scenes.new('main')
+        bpy.context.window.scene = main_scene
+
+        # Update depsgraph.
+        main_scene.update()
+        background_scene.update()
+
+        # Safety check, there should be no objects in thew newly created scene.
+        self.assertEqual(0, len(bpy.context.depsgraph.objects))
+
+        # Now set the background set, and objects relationship.
+        main_scene.background_set = background_scene
+        background_scene.objects[0].parent = background_scene.objects[1]
+
+        # Update depsgraph.
+        main_scene.update()
+        background_scene.update()
+
+        # Test if objects were properly added to depsgraph.
+        self.assertEqual(3, len(bpy.context.depsgraph.objects))
+
+        # At this point the ideal would be to be able to check if
+        # the objects are not selected and their relationship line
+        # and origin is not visible.
+        #
+        # However we can't check this from the current API
+        # so we either do image comparison, expand the API
+        # (won't work relationship lines) or leave as it is.
+
+        # Test if removing is working fine.
+        main_scene.background_set = None
+
+        # Update depsgraph.
+        main_scene.update()
+        background_scene.update()
+
+        self.assertEqual(0, len(bpy.context.depsgraph.objects))
+
+
+# ############################################################
+# Main - Same For All Render Layer Tests
+# ############################################################
+
+if __name__ == '__main__':
+    UnitTesting._extra_arguments = setup_extra_arguments(__file__)
+    unittest.main()



More information about the Bf-blender-cvs mailing list