Commit: 5a5f1dc8e495d8c3e8c4acce0f45830e968979c2 Author: Dalai Felinto Date: Thu Apr 13 16:28:47 2017 +0200 Branches: blender2.8 https://developer.blender.org/rB5a5f1dc8e495d8c3e8c4acce0f45830e968979c2
Unittests for depsgraph layer collection render settings evaluation Some of the tests are failing at the moment. Those problems were introduced in eba09b1520 =================================================================== M tests/python/render_layer/CMakeLists.txt M tests/python/render_layer/render_layer_common.py A tests/python/render_layer/test_evaluation_render_settings_a.py A tests/python/render_layer/test_evaluation_render_settings_b.py A tests/python/render_layer/test_evaluation_render_settings_c.py A tests/python/render_layer/test_evaluation_render_settings_d.py A tests/python/render_layer/test_evaluation_render_settings_e.py A tests/python/render_layer/test_evaluation_render_settings_f.py A tests/python/render_layer/test_evaluation_render_settings_g.py =================================================================== diff --git a/tests/python/render_layer/CMakeLists.txt b/tests/python/render_layer/CMakeLists.txt index efe7e280a41..2ec944d693f 100644 --- a/tests/python/render_layer/CMakeLists.txt +++ b/tests/python/render_layer/CMakeLists.txt @@ -62,6 +62,13 @@ endmacro() RENDER_LAYER_TEST(active_collection) RENDER_LAYER_TEST(collection_rename) +RENDER_LAYER_TEST(evaluation_render_settings_a) +RENDER_LAYER_TEST(evaluation_render_settings_b) +RENDER_LAYER_TEST(evaluation_render_settings_c) +RENDER_LAYER_TEST(evaluation_render_settings_d) +RENDER_LAYER_TEST(evaluation_render_settings_e) +RENDER_LAYER_TEST(evaluation_render_settings_f) +RENDER_LAYER_TEST(evaluation_render_settings_g) RENDER_LAYER_TEST(evaluation_visibility_a) RENDER_LAYER_TEST(evaluation_visibility_b) RENDER_LAYER_TEST(evaluation_visibility_c) diff --git a/tests/python/render_layer/render_layer_common.py b/tests/python/render_layer/render_layer_common.py index 4fb714e429e..586b9dd0af9 100644 --- a/tests/python/render_layer/render_layer_common.py +++ b/tests/python/render_layer/render_layer_common.py @@ -693,3 +693,88 @@ class MoveLayerCollectionTesting(MoveSceneCollectionSyncTesting): layer_collection_src = self.parse_move(src) layer_collection_dst = self.parse_move(dst) return layer_collection_src.move_below(layer_collection_dst) + + +class Clay: + def __init__(self, extra_kid_layer=False): + import bpy + + self._scene = bpy.context.scene + self._layer = self._fresh_layer() + self._object = bpy.data.objects.new('guinea pig', bpy.data.meshes.new('mesh')) + + # update depsgraph + self._scene.update() + + scene_collection_grandma = self._scene.master_collection.collections.new("Grandma") + scene_collection_mom = scene_collection_grandma.collections.new("Mom") + scene_collection_kid = scene_collection_mom.collections.new("Kid") + scene_collection_kid.objects.link(self._object) + + layer_collection_grandma = self._layer.collections.link(scene_collection_grandma) + layer_collection_mom = layer_collection_grandma.collections[0] + layer_collection_kid = layer_collection_mom.collections[0] + + # store the variables + self._scene_collections = { + 'grandma': scene_collection_grandma, + 'mom': scene_collection_mom, + 'kid': scene_collection_kid, + } + self._layer_collections = { + 'grandma': layer_collection_grandma, + 'mom': layer_collection_mom, + 'kid': layer_collection_kid, + } + + if extra_kid_layer: + layer_collection_extra = self._layer.collections.link(scene_collection_kid) + self._layer_collections['extra'] = layer_collection_extra + + self._update() + + def _fresh_layer(self): + import bpy + + # remove all other objects + while bpy.data.objects: + bpy.data.objects.remove(bpy.data.objects[0]) + + layer = self._scene.render_layers.new('Evaluation Test') + layer.collections.unlink(layer.collections[0]) + self._scene.render_layers.active = layer + + # remove all other layers + for layer_iter in self._scene.render_layers: + if layer_iter != layer: + self._scene.render_layers.remove(layer_iter) + + return layer + + def _update(self): + """ + Force depsgrpah evaluation + and update pointers to IDProperty collections + """ + ENGINE = 'BLENDER_CLAY' + + self._scene.update() # update depsgraph + self._layer.update() # flush depsgraph evaluation + + # change scene settings + self._properties = { + 'scene': self._scene.collection_properties[ENGINE], + 'object': self._object.collection_properties[ENGINE], + } + + for key, value in self._layer_collections.items(): + self._properties[key] = self._layer_collections[key].engine_overrides[ENGINE] + + def get(self, name, data_path): + self._update() + return getattr(self._properties[name], data_path) + + def set(self, name, data_path, value): + self._update() + self._properties[name].use(data_path) + setattr(self._properties[name], data_path, value) diff --git a/tests/python/render_layer/test_evaluation_render_settings_a.py b/tests/python/render_layer/test_evaluation_render_settings_a.py new file mode 100644 index 00000000000..62565adaff1 --- /dev/null +++ b/tests/python/render_layer/test_evaluation_render_settings_a.py @@ -0,0 +1,38 @@ +# ############################################################ +# Importing - Same For All Render Layer Tests +# ############################################################ + +import unittest +import os +import sys + +from render_layer_common import * + + +# ############################################################ +# Testing +# ############################################################ + +class UnitTesting(RenderLayerTesting): + def test_render_settings(self): + """ + See if the depsgraph evaluation is correct + """ + clay = Clay() + self.assertEqual(clay.get('object', 'matcap_icon'), '01') + clay.set('scene', 'matcap_icon', '05') + self.assertEqual(clay.get('object', 'matcap_icon'), '05') + + +# ############################################################ +# 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_evaluation_render_settings_b.py b/tests/python/render_layer/test_evaluation_render_settings_b.py new file mode 100644 index 00000000000..64475dabfc3 --- /dev/null +++ b/tests/python/render_layer/test_evaluation_render_settings_b.py @@ -0,0 +1,39 @@ +# ############################################################ +# Importing - Same For All Render Layer Tests +# ############################################################ + +import unittest +import os +import sys + +from render_layer_common import * + + +# ############################################################ +# Testing +# ############################################################ + +class UnitTesting(RenderLayerTesting): + def test_render_settings(self): + """ + See if the depsgraph evaluation is correct + """ + clay = Clay() + self.assertEqual(clay.get('object', 'matcap_icon'), '01') + clay.set('scene', 'matcap_icon', '05') + clay.set('grandma', 'matcap_icon', '03') + self.assertEqual(clay.get('object', 'matcap_icon'), '03') + + +# ############################################################ +# 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_evaluation_render_settings_c.py b/tests/python/render_layer/test_evaluation_render_settings_c.py new file mode 100644 index 00000000000..325a4efdfc0 --- /dev/null +++ b/tests/python/render_layer/test_evaluation_render_settings_c.py @@ -0,0 +1,38 @@ +# ############################################################ +# Importing - Same For All Render Layer Tests +# ############################################################ + +import unittest +import os +import sys + +from render_layer_common import * + + +# ############################################################ +# Testing +# ############################################################ + +class UnitTesting(RenderLayerTesting): + def test_render_settings(self): + """ + See if the depsgraph evaluation is correct + """ + clay = Clay() + self.assertEqual(clay.get('object', 'matcap_icon'), '01') + clay.set('mom', 'matcap_icon', '02') + self.assertEqual(clay.get('object', 'matcap_icon'), '02') + + +# ############################################################ +# 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_evaluation_render_settings_d.py b/tests/python/render_layer/test_evaluation_render_settings_d.py new file mode 100644 index 00000000000..faa3d437aca --- /dev/null +++ b/tests/python/render_layer/test_evaluation_render_settings_d.py @@ -0,0 +1,38 @@ +# ############################################################ +# Importing - Same For All Render Layer Tests +# ############################################################ + +import unittest +import os +import sys + +from render_layer_common import * + + +# ############################################################ +# Testing +# ############################################################ + +class UnitTesting(RenderLayerTesting): + def test_render_settings(self): + """ + See if the depsgraph evaluation is correct + """ + clay = Clay() + self.assertEqual(clay.get('object', 'matcap_icon'), '01') + clay.set('kid', 'matcap_icon', '05') + self.assertEqual(clay.get('object', 'matcap_icon'), '05') + + +# ############################################################ +# Main - Same For All Render Layer Tests +# ####################################################### @@ Diff output truncated at 10240 characters. @@ _______________________________________________ Bf-blender-cvs mailing list Bf-blender-cvs@blender.org https://lists.blender.org/mailman/listinfo/bf-blender-cvs