diff options
25 files changed, 1626 insertions, 70 deletions
diff --git a/source/blender/blenkernel/BKE_layer.h b/source/blender/blenkernel/BKE_layer.h index 14324f27bfe..212b7a31d38 100644 --- a/source/blender/blenkernel/BKE_layer.h +++ b/source/blender/blenkernel/BKE_layer.h @@ -66,7 +66,7 @@ void BKE_scene_layer_engine_set(struct SceneLayer *sl, const char *engine); void BKE_scene_layer_selected_objects_tag(struct SceneLayer *sl, const int tag); -struct SceneLayer *BKE_scene_layer_find_from_collection(struct Scene *scene, struct LayerCollection *lc); +struct SceneLayer *BKE_scene_layer_find_from_collection(const struct Scene *scene, struct LayerCollection *lc); struct Base *BKE_scene_layer_base_find(struct SceneLayer *sl, struct Object *ob); void BKE_scene_layer_base_deselect_all(struct SceneLayer *sl); void BKE_scene_layer_base_select(struct SceneLayer *sl, struct Base *selbase); @@ -83,9 +83,7 @@ struct LayerCollection *BKE_layer_collection_active(struct SceneLayer *sl); int BKE_layer_collection_count(struct SceneLayer *sl); -int BKE_layer_collection_findindex(struct SceneLayer *sl, struct LayerCollection *lc); -bool BKE_layer_collection_reinsert_after(const struct Scene *scene, struct SceneLayer *sl, - struct LayerCollection *lc_reinsert, struct LayerCollection *lc_after); +int BKE_layer_collection_findindex(struct SceneLayer *sl, const struct LayerCollection *lc); bool BKE_layer_collection_move_above(const struct Scene *scene, struct LayerCollection *lc_dst, struct LayerCollection *lc_src); bool BKE_layer_collection_move_below(const struct Scene *scene, struct LayerCollection *lc_dst, struct LayerCollection *lc_src); diff --git a/source/blender/blenkernel/intern/layer.c b/source/blender/blenkernel/intern/layer.c index fb1a35d210c..6da7cb13298 100644 --- a/source/blender/blenkernel/intern/layer.c +++ b/source/blender/blenkernel/intern/layer.c @@ -192,7 +192,7 @@ static bool find_scene_collection_in_scene_collections(ListBase *lb, const Layer /** * Find the SceneLayer a LayerCollection belongs to */ -SceneLayer *BKE_scene_layer_find_from_collection(Scene *scene, LayerCollection *lc) +SceneLayer *BKE_scene_layer_find_from_collection(const Scene *scene, LayerCollection *lc) { for (SceneLayer *sl = scene->render_layers.first; sl; sl = sl->next) { if (find_scene_collection_in_scene_collections(&sl->layer_collections, lc)) { @@ -465,7 +465,7 @@ int BKE_layer_collection_count(SceneLayer *sl) /** * Recursively get the index for a given collection */ -static int index_from_collection(ListBase *lb, LayerCollection *lc, int *i) +static int index_from_collection(ListBase *lb, const LayerCollection *lc, int *i) { for (LayerCollection *lcol = lb->first; lcol; lcol = lcol->next) { if (lcol == lc) { @@ -485,7 +485,7 @@ static int index_from_collection(ListBase *lb, LayerCollection *lc, int *i) /** * Return -1 if not found */ -int BKE_layer_collection_findindex(SceneLayer *sl, LayerCollection *lc) +int BKE_layer_collection_findindex(SceneLayer *sl, const LayerCollection *lc) { int i = 0; return index_from_collection(&sl->layer_collections, lc, &i); @@ -510,6 +510,7 @@ static ListBase *layer_collection_listbase_find(ListBase *lb, LayerCollection *l return NULL; } +#if 0 /** * Lookup the listbase that contains \a sc. */ @@ -528,50 +529,7 @@ static ListBase *scene_collection_listbase_find(ListBase *lb, SceneCollection *s return NULL; } - -/** - * Move \a lc_reinsert so that it follows \a lc_after. Both have to be stored in \a sl. - * \param lc_after: Can be NULL to reinsert \a lc_after as first collection of its own list. - */ -bool BKE_layer_collection_reinsert_after( - const Scene *scene, SceneLayer *sl, LayerCollection *lc_reinsert, LayerCollection *lc_after) -{ - /* TODO this function probably needs to be rewritten completely to support all cases - * (reinserting master collection, reinsert into different hierarchy levels, etc) */ - TODO_LAYER_OPERATORS; -#if 0 - SceneCollection *sc_master = BKE_collection_master(scene); - SceneCollection *sc_reinsert = lc_reinsert->scene_collection; - ListBase *lc_reinsert_lb = layer_collection_listbase_find(&sl->layer_collections, lc_reinsert); - ListBase *sc_reinsert_lb = scene_collection_listbase_find(&sc_master->scene_collections, sc_reinsert); - - BLI_assert(BLI_findindex(lc_reinsert_lb, lc_reinsert) > -1); - BLI_assert(BLI_findindex(sc_reinsert_lb, sc_reinsert) > -1); - BLI_remlink(lc_reinsert_lb, lc_reinsert); - BLI_remlink(sc_reinsert_lb, sc_reinsert); - - /* insert after lc_after or */ - if (lc_after == NULL) { - BLI_addhead(lc_reinsert_lb, lc_reinsert); - BLI_addhead(sc_reinsert_lb, sc_reinsert); - } - else { - SceneCollection *sc_after = lc_after->scene_collection; - ListBase *lc_after_lb = layer_collection_listbase_find(&sl->layer_collections, lc_after); - ListBase *sc_after_lb = scene_collection_listbase_find(&sc_master->scene_collections, sc_after); - - BLI_insertlinkafter(lc_after_lb, lc_after, lc_reinsert); - BLI_insertlinkafter(sc_after_lb, sc_after, sc_reinsert); - } - - BKE_scene_layer_base_flag_recalculate(sl); - BKE_scene_layer_engine_settings_collection_recalculate(sl, lc_reinsert); -#else - UNUSED_VARS(scene, sl, lc_reinsert, lc_after); - UNUSED_VARS(layer_collection_listbase_find, scene_collection_listbase_find); - return false; #endif -} /* ---------------------------------------------------------------------- */ /* Outliner drag and drop */ @@ -590,28 +548,233 @@ bool BKE_layer_collection_reinsert_after( * \param lc_src LayerCollection to nest into \a lc_dst * \param lc_dst LayerCollection to have \a lc_src inserted into */ -bool BKE_layer_collection_move_into(const Scene *scene, LayerCollection *lc_src, LayerCollection *lc_dst) + +static void layer_collection_swap( + SceneLayer *sl, ListBase *lb_a, ListBase *lb_b, + LayerCollection *lc_a, LayerCollection *lc_b) { - /* TODO this is missing */ - TODO_LAYER_OPERATORS; - UNUSED_VARS(scene, lc_src, lc_dst); - return false; + if (lb_a == NULL) { + lb_a = layer_collection_listbase_find(&sl->layer_collections, lc_a); + } + + if (lb_b == NULL) { + lb_b = layer_collection_listbase_find(&sl->layer_collections, lc_b); + } + + BLI_assert(lb_a); + BLI_assert(lb_b); + + BLI_listbases_swaplinks(lb_a, lb_b, lc_a, lc_b); +} + +/** + * Move \a lc_src into \a lc_dst. Both have to be stored in \a sl. + * If \a lc_src is directly linked to the SceneLayer it's unlinked + */ +bool BKE_layer_collection_move_into(const Scene *scene, LayerCollection *lc_dst, LayerCollection *lc_src) +{ + SceneLayer *sl = BKE_scene_layer_find_from_collection(scene, lc_src); + bool is_directly_linked = false; + + if ((!sl) || (sl != BKE_scene_layer_find_from_collection(scene, lc_dst))) { + return false; + } + + /* Collection is already where we wanted it to be */ + if (lc_dst->layer_collections.last == lc_src) { + return false; + } + + /* Collection is already where we want it to be in the scene tree + * but we want to swap it in the layer tree still */ + if (lc_dst->scene_collection->scene_collections.last == lc_src->scene_collection) { + LayerCollection *lc_swap = lc_dst->layer_collections.last; + layer_collection_swap(sl, &lc_dst->layer_collections, NULL, lc_dst->layer_collections.last, lc_src); + + if (BLI_findindex(&sl->layer_collections, lc_swap) != -1) { + BKE_collection_unlink(sl, lc_swap); + } + return true; + } + else { + LayerCollection *lc_temp; + is_directly_linked = BLI_findindex(&sl->layer_collections, lc_src) != -1; + + if (!is_directly_linked) { + /* lc_src will be invalid after BKE_collection_move_into! + * so we swap it with lc_temp to preserve its settings */ + lc_temp = BKE_collection_link(sl, lc_src->scene_collection); + layer_collection_swap(sl, &sl->layer_collections, NULL, lc_temp, lc_src); + } + + if (!BKE_collection_move_into(scene, lc_dst->scene_collection, lc_src->scene_collection)) { + if (!is_directly_linked) { + /* Swap back and remove */ + layer_collection_swap(sl, NULL, NULL, lc_temp, lc_src); + BKE_collection_unlink(sl, lc_temp); + } + return false; + } + } + + LayerCollection *lc_new = BLI_findptr(&lc_dst->layer_collections, lc_src->scene_collection, offsetof(LayerCollection, scene_collection)); + BLI_assert(lc_new); + layer_collection_swap(sl, &lc_dst->layer_collections, NULL, lc_new, lc_src); + + /* If it's directly linked, unlink it after the swap */ + if (BLI_findindex(&sl->layer_collections, lc_new) != -1) { + BKE_collection_unlink(sl, lc_new); + } + + return true; } +/** + * Move \a lc_src above \a lc_dst. Both have to be stored in \a sl. + * If \a lc_src is directly linked to the SceneLayer it's unlinked + */ bool BKE_layer_collection_move_above(const Scene *scene, LayerCollection *lc_dst, LayerCollection *lc_src) { - /* TODO this is missing */ - TODO_LAYER_OPERATORS; - UNUSED_VARS(scene, lc_dst, lc_src); - return false; + SceneLayer *sl = BKE_scene_layer_find_from_collection(scene, lc_src); + const bool is_directly_linked_src = BLI_findindex(&sl->layer_collections, lc_src) != -1; + const bool is_directly_linked_dst = BLI_findindex(&sl->layer_collections, lc_dst) != -1; + + if ((!sl) || (sl != BKE_scene_layer_find_from_collection(scene, lc_dst))) { + return false; + } + + /* Collection is already where we wanted it to be */ + if (lc_dst->prev == lc_src) { + return false; + } + + /* Collection is already where we want it to be in the scene tree + * but we want to swap it in the layer tree still */ + if (lc_dst->prev && lc_dst->prev->scene_collection == lc_src->scene_collection) { + LayerCollection *lc_swap = lc_dst->prev; + layer_collection_swap(sl, NULL, NULL, lc_dst->prev, lc_src); + + if (BLI_findindex(&sl->layer_collections, lc_swap) != -1) { + BKE_collection_unlink(sl, lc_swap); + } + return true; + } + /* We don't allow to move above/below a directly linked collection + * unless the source collection is also directly linked */ + else if (is_directly_linked_dst) { + /* Both directly linked to the SceneLayer, just need to swap */ + if (is_directly_linked_src) { + BLI_listbase_swaplinks(&sl->layer_collections, lc_src, lc_dst); + return true; + } + else { + return false; + } + } + else { + LayerCollection *lc_temp; + + if (!is_directly_linked_src) { + /* lc_src will be invalid after BKE_collection_move_into! + * so we swap it with lc_temp to preserve its settings */ + lc_temp = BKE_collection_link(sl, lc_src->scene_collection); + layer_collection_swap(sl, &sl->layer_collections, NULL, lc_temp, lc_src); + } + + if (!BKE_collection_move_above(scene, lc_dst->scene_collection, lc_src->scene_collection)) { + if (!is_directly_linked_src) { + /* Swap back and remove */ + layer_collection_swap(sl, NULL, NULL, lc_temp, lc_src); + BKE_collection_unlink(sl, lc_temp); + } + return false; + } + } + + LayerCollection *lc_new = lc_dst->prev; + BLI_assert(lc_new); + layer_collection_swap(sl, NULL, NULL, lc_new, lc_src); + + /* If it's directly linked, unlink it after the swap */ + if (BLI_findindex(&sl->layer_collections, lc_new) != -1) { + BKE_collection_unlink(sl, lc_new); + } + + return true; } +/** + * Move \a lc_src below \a lc_dst. Both have to be stored in \a sl. + * If \a lc_src is directly linked to the SceneLayer it's unlinked + */ bool BKE_layer_collection_move_below(const Scene *scene, LayerCollection *lc_dst, LayerCollection *lc_src) { - /* TODO this is missing */ - TODO_LAYER_OPERATORS; - UNUSED_VARS(scene, lc_dst, lc_src); - return false; + SceneLayer *sl = BKE_scene_layer_find_from_collection(scene, lc_src); + const bool is_directly_linked_src = BLI_findindex(&sl->layer_collections, lc_src) != -1; + const bool is_directly_linked_dst = BLI_findindex(&sl->layer_collections, lc_dst) != -1; + + if ((!sl) || (sl != BKE_scene_layer_find_from_collection(scene, lc_dst))) { + return false; + } + + /* Collection is already where we wanted it to be */ + if (lc_dst->next == lc_src) { + return false; + } + + /* Collection is already where we want it to be in the scene tree + * but we want to swap it in the layer tree still */ + if (lc_dst->next && lc_dst->next->scene_collection == lc_src->scene_collection) { + LayerCollection *lc_swap = lc_dst->next; + layer_collection_swap(sl, NULL, NULL, lc_dst->next, lc_src); + + if (BLI_findindex(&sl->layer_collections, lc_swap) != -1) { + BKE_collection_unlink(sl, lc_swap); + } + return true; + } + /* We don't allow to move above/below a directly linked collection + * unless the source collection is also directly linked */ + else if (is_directly_linked_dst) { + /* Both directly linked to the SceneLayer, just need to swap */ + if (is_directly_linked_src) { + BLI_listbase_swaplinks(&sl->layer_collections, lc_src, lc_dst); + return true; + } + else { + return false; + } + } + else { + LayerCollection *lc_temp; + + if (!is_directly_linked_src) { + /* lc_src will be invalid after BKE_collection_move_into! + * so we swap it with lc_temp to preserve its settings */ + lc_temp = BKE_collection_link(sl, lc_src->scene_collection); + layer_collection_swap(sl, &sl->layer_collections, NULL, lc_temp, lc_src); + } + + if (!BKE_collection_move_below(scene, lc_dst->scene_collection, lc_src->scene_collection)) { + if (!is_directly_linked_src) { + /* Swap back and remove */ + layer_collection_swap(sl, NULL, NULL, lc_temp, lc_src); + BKE_collection_unlink(sl, lc_temp); + } + return false; + } + } + + LayerCollection *lc_new = lc_dst->next; + BLI_assert(lc_new); + layer_collection_swap(sl, NULL, NULL, lc_new, lc_src); + + /* If it's directly linked, unlink it after the swap */ + if (BLI_findindex(&sl->layer_collections, lc_new) != -1) { + BKE_collection_unlink(sl, lc_new); + } + + return true; } static bool layer_collection_resync(SceneLayer *sl, LayerCollection *lc, const SceneCollection *sc) diff --git a/source/blender/editors/space_outliner/outliner_tree.c b/source/blender/editors/space_outliner/outliner_tree.c index 1db530804b7..870c34a1ee7 100644 --- a/source/blender/editors/space_outliner/outliner_tree.c +++ b/source/blender/editors/space_outliner/outliner_tree.c @@ -1290,15 +1290,23 @@ static void outliner_add_orphaned_datablocks(Main *mainvar, SpaceOops *soops) static void outliner_layer_collections_reorder(const Scene *scene, TreeElement *insert_element, TreeElement *insert_handle, TreeElementInsertType action) { - SceneLayer *sl = BKE_scene_layer_render_active(scene); - LayerCollection *insert_coll = insert_element->directdata; - LayerCollection *insert_handle_coll = insert_handle ? insert_handle->directdata : NULL; + LayerCollection *sc_src = insert_element->directdata; + LayerCollection *sc_dst = insert_handle ? insert_handle->directdata : NULL; if (action == TE_INSERT_AFTER) { - BKE_layer_collection_reinsert_after(scene, sl, insert_coll, insert_handle_coll); + if (sc_dst == NULL) { + /* It needs a LayerCollection to use as reference, + * specially now that we are to allow insert in collections + * that don't belong to the same hierarchical level */ + TODO_LAYER_OPERATORS; + /* BKE_layer_collection_move_after(scene, sc_dst, sc_src); */ + } + else { + BKE_layer_collection_move_below(scene, sc_dst, sc_src); + } } else if (action == TE_INSERT_INTO) { - BKE_layer_collection_move_into(scene, insert_coll, insert_handle_coll); + BKE_layer_collection_move_into(scene, sc_src, sc_dst); } } @@ -1312,7 +1320,7 @@ static void outliner_scene_collections_reorder(const Scene *scene, TreeElement * if (sc_dst == NULL) { /* It needs a SceneCollection to use as reference, * specially now that we are to allow insert in collections - * that don't belong to the same hierarchical level*/ + * that don't belong to the same hierarchical level */ TODO_LAYER_OPERATORS; /* BKE_collection_move_after(scene, sc_dst, sc_src); */ } diff --git a/tests/python/render_layer/CMakeLists.txt b/tests/python/render_layer/CMakeLists.txt index ff31d1c29f4..d037b9cd3b7 100644 --- a/tests/python/render_layer/CMakeLists.txt +++ b/tests/python/render_layer/CMakeLists.txt @@ -114,6 +114,26 @@ RENDER_LAYER_TEST(move_into_scene_collection_sync_i) RENDER_LAYER_TEST(move_into_scene_collection_sync_j) RENDER_LAYER_TEST(move_into_scene_collection_sync_k) RENDER_LAYER_TEST(move_into_scene_collection_sync_l) +RENDER_LAYER_TEST(move_above_below_layer_collection_a) +RENDER_LAYER_TEST(move_above_below_layer_collection_b) +RENDER_LAYER_TEST(move_above_below_layer_collection_c) +RENDER_LAYER_TEST(move_above_below_layer_collection_d) +RENDER_LAYER_TEST(move_above_below_layer_collection_e) +RENDER_LAYER_TEST(move_above_below_layer_collection_f) +RENDER_LAYER_TEST(move_above_below_layer_collection_g) +RENDER_LAYER_TEST(move_above_below_layer_collection_h) +RENDER_LAYER_TEST(move_above_below_layer_collection_i) +RENDER_LAYER_TEST(move_above_below_layer_collection_j) +RENDER_LAYER_TEST(move_above_below_layer_collection_k) +RENDER_LAYER_TEST(move_into_layer_collection_a) +RENDER_LAYER_TEST(move_into_layer_collection_b) +RENDER_LAYER_TEST(move_into_layer_collection_c) +RENDER_LAYER_TEST(move_into_layer_collection_d) +RENDER_LAYER_TEST(move_into_layer_collection_e) +RENDER_LAYER_TEST(move_into_layer_collection_f) +RENDER_LAYER_TEST(move_into_layer_collection_g) +RENDER_LAYER_TEST(move_into_layer_collection_h) +RENDER_LAYER_TEST(move_into_layer_collection_i) RENDER_LAYER_TEST(layer_linking) RENDER_LAYER_TEST(layer_syncinc) RENDER_LAYER_TEST(scene_copy) diff --git a/tests/python/render_layer/render_layer_common.py b/tests/python/render_layer/render_layer_common.py index cdee2bd066b..ddfbc629605 100644 --- a/tests/python/render_layer/render_layer_common.py +++ b/tests/python/render_layer/render_layer_common.py @@ -467,6 +467,12 @@ class MoveSceneCollectionSyncTesting(MoveSceneCollectionTesting): ] return layers_map + def get_reference_layers_tree_map(self): + """ + For those classes we don't expect any changes in the layer tree + """ + return self.get_initial_layers_tree_map() + def setup_tree(self): tree = super(MoveSceneCollectionSyncTesting, self).setup_tree() @@ -493,7 +499,7 @@ class MoveSceneCollectionSyncTesting(MoveSceneCollectionTesting): import bpy scene = bpy.context.scene - layers_map = self.get_initial_layers_tree_map() + layers_map = self.get_reference_layers_tree_map() for layer_name, collections_names in layers_map: layer = scene.render_layers.get(layer_name) @@ -515,3 +521,41 @@ class MoveSceneCollectionSyncTesting(MoveSceneCollectionTesting): self.assertEqual(nested_collection.collection.name, scene_collection.collections[i].name) self.assertEqual(nested_collection.collection, scene_collection.collections[i]) self.verify_collection_tree(nested_collection) + + +class MoveLayerCollectionTesting(MoveSceneCollectionSyncTesting): + """ + To be used by tests of render_layer_move_into_layer_collection + """ + def parse_move(self, path, sep='.'): + """ + convert 'Layer 1.C.2' into: + bpy.context.scene.render_layers['Layer 1'].collections['C'].collections['2'] + """ + import bpy + + paths = path.split(sep) + layer = bpy.context.scene.render_layers[paths[0]] + collections = layer.collections + + for subpath in paths[1:]: + collection = collections[subpath] + collections = collection.collections + + return collection + + def move_into(self, src, dst): + layer_collection_src = self.parse_move(src) + layer_collection_dst = self.parse_move(dst) + return layer_collection_src.move_into(layer_collection_dst) + + def move_above(self, src, dst): + layer_collection_src = self.parse_move(src) + layer_collection_dst = self.parse_move(dst) + return layer_collection_src.move_above(layer_collection_dst) + + def move_below(self, src, dst): + layer_collection_src = self.parse_move(src) + layer_collection_dst = self.parse_move(dst) + return layer_collection_src.move_below(layer_collection_dst) + diff --git a/tests/python/render_layer/test_move_above_below_layer_collection_a.py b/tests/python/render_layer/test_move_above_below_layer_collection_a.py new file mode 100644 index 00000000000..0eb96660199 --- /dev/null +++ b/tests/python/render_layer/test_move_above_below_layer_collection_a.py @@ -0,0 +1,56 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_move_a(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_below('Layer 1.3', 'Layer 1.C')) + self.compare_tree_maps() + + def test_layer_collection_move_b(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_above('Layer 1.C', 'Layer 1.3')) + self.compare_tree_maps() + + +# ############################################################ +# 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_move_above_below_layer_collection_b.py b/tests/python/render_layer/test_move_above_below_layer_collection_b.py new file mode 100644 index 00000000000..18e879098a2 --- /dev/null +++ b/tests/python/render_layer/test_move_above_below_layer_collection_b.py @@ -0,0 +1,56 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_move_a(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_below('Layer 1.3.cat', 'Layer 1.3.dog')) + self.compare_tree_maps() + + def test_layer_collection_move_b(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_above('Layer 1.3.dog', 'Layer 1.3.cat')) + self.compare_tree_maps() + + +# ############################################################ +# 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_move_above_below_layer_collection_c.py b/tests/python/render_layer/test_move_above_below_layer_collection_c.py new file mode 100644 index 00000000000..18e879098a2 --- /dev/null +++ b/tests/python/render_layer/test_move_above_below_layer_collection_c.py @@ -0,0 +1,56 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_move_a(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_below('Layer 1.3.cat', 'Layer 1.3.dog')) + self.compare_tree_maps() + + def test_layer_collection_move_b(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_above('Layer 1.3.dog', 'Layer 1.3.cat')) + self.compare_tree_maps() + + +# ############################################################ +# 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_move_above_below_layer_collection_d.py b/tests/python/render_layer/test_move_above_below_layer_collection_d.py new file mode 100644 index 00000000000..0c54b34453d --- /dev/null +++ b/tests/python/render_layer/test_move_above_below_layer_collection_d.py @@ -0,0 +1,56 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_move_a(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_above('Layer 2.3.dog', 'Layer 1.C.2')) + self.compare_tree_maps() + + def test_layer_collection_move_b(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_below('Layer 1.C.2', 'Layer 2.3.dog')) + self.compare_tree_maps() + + +# ############################################################ +# 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_move_above_below_layer_collection_e.py b/tests/python/render_layer/test_move_above_below_layer_collection_e.py new file mode 100644 index 00000000000..634cb537682 --- /dev/null +++ b/tests/python/render_layer/test_move_above_below_layer_collection_e.py @@ -0,0 +1,48 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_move(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_below('Layer 1.Master Collection', 'Layer 1.C.1')) + self.compare_tree_maps() + + +# ############################################################ +# 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_move_above_below_layer_collection_f.py b/tests/python/render_layer/test_move_above_below_layer_collection_f.py new file mode 100644 index 00000000000..26ac9a734c9 --- /dev/null +++ b/tests/python/render_layer/test_move_above_below_layer_collection_f.py @@ -0,0 +1,108 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + reference_tree_map = [ + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['3', [ + ['dog', None], + ['cat', None], + ]], + ['2', None], + ]], + ] + return reference_tree_map + + def get_reference_layers_tree_map(self): + reference_layers_map = [ + ['Layer 1', [ + 'Master Collection', + 'C', + '3', + ]], + ['Layer 2', [ + 'C', + 'dog', + 'cat', + ]], + ] + return reference_layers_map + + def test_layer_collection_move_a(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertTrue(self.move_below('Layer 2.3', 'Layer 2.C.1')) + self.compare_tree_maps() + + def test_layer_collection_move_b(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertTrue(self.move_above('Layer 2.3', 'Layer 2.C.2')) + self.compare_tree_maps() + + def test_layer_collection_move_c(self): + """ + Test outliner operations + """ + self.setup_tree() + + # collection that will be moved + collection_original = self.parse_move('Layer 2.3') + collection_original.hide = False + collection_original.hide_select = True + + # collection that will disappear + collection_old = self.parse_move('Layer 2.C.3') + collection_old.hide = True + collection_old.hide_select = False + + # move + self.assertTrue(self.move_below('Layer 2.3', 'Layer 2.C.1')) + self.compare_tree_maps() + + # we expect the settings to be carried along from the + # original layer collection + collection_new = self.parse_move('Layer 2.C.3') + self.assertEqual(collection_new.hide, False) + self.assertEqual(collection_new.hide_select, True) + + +# ############################################################ +# 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_move_above_below_layer_collection_g.py b/tests/python/render_layer/test_move_above_below_layer_collection_g.py new file mode 100644 index 00000000000..d52866fba68 --- /dev/null +++ b/tests/python/render_layer/test_move_above_below_layer_collection_g.py @@ -0,0 +1,89 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + reference_tree_map = [ + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['cat', None], + ['dog', None], + ]], + ]], + ] + return reference_tree_map + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_move_a(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertTrue(self.move_above('Layer 2.C.3.cat', 'Layer 2.3.dog')) + self.compare_tree_maps() + + def test_layer_collection_move_b(self): + """ + Test outliner operations + """ + self.setup_tree() + + # collection that will be moved + collection_original = self.parse_move('Layer 2.C.3.cat') + collection_original.hide = False + collection_original.hide_select = True + + # collection that will disappear + collection_old = self.parse_move('Layer 2.3.cat') + collection_old.hide = True + collection_old.hide_select = False + + # move + self.assertTrue(self.move_above('Layer 2.C.3.cat', 'Layer 2.3.dog')) + self.compare_tree_maps() + + # we expect the settings to be carried along from the + # original layer collection + collection_new = self.parse_move('Layer 2.3.cat') + self.assertEqual(collection_new.hide, False) + self.assertEqual(collection_new.hide_select, True) + + +# ############################################################ +# 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_move_above_below_layer_collection_h.py b/tests/python/render_layer/test_move_above_below_layer_collection_h.py new file mode 100644 index 00000000000..f20c429ec41 --- /dev/null +++ b/tests/python/render_layer/test_move_above_below_layer_collection_h.py @@ -0,0 +1,74 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_move_a(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertTrue(self.move_below('Layer 2.C.3.cat', 'Layer 2.3.dog')) + self.compare_tree_maps() + + def test_layer_collection_move_b(self): + """ + Test outliner operations + """ + self.setup_tree() + + # collection that will be moved + collection_original = self.parse_move('Layer 2.C.3.cat') + collection_original.hide = False + collection_original.hide_select = True + + # collection that will disappear + collection_old = self.parse_move('Layer 2.3.cat') + collection_old.hide = True + collection_old.hide_select = False + + # move + self.assertTrue(self.move_below('Layer 2.C.3.cat', 'Layer 2.3.dog')) + self.compare_tree_maps() + + # we expect the settings to be carried along from the + # original layer collection + collection_new = self.parse_move('Layer 2.3.cat') + self.assertEqual(collection_new.hide, False) + self.assertEqual(collection_new.hide_select, True) + + +# ############################################################ +# 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_move_above_below_layer_collection_i.py b/tests/python/render_layer/test_move_above_below_layer_collection_i.py new file mode 100644 index 00000000000..b3601a34bcd --- /dev/null +++ b/tests/python/render_layer/test_move_above_below_layer_collection_i.py @@ -0,0 +1,81 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + reference_layers_map = [ + ['Layer 1', [ + 'Master Collection', + 'C', + '3', + ]], + ['Layer 2', [ + '3', + 'C', + 'dog', + 'cat', + ]], + ] + return reference_layers_map + + def test_layer_collection_move_a(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertTrue(self.move_below('Layer 2.C', 'Layer 2.3')) + self.compare_tree_maps() + + def test_layer_collection_move_b(self): + """ + Test outliner operations + """ + self.setup_tree() + + # collection that will be moved + collection_original = self.parse_move('Layer 2.C') + collection_original.hide = False + collection_original.hide_select = True + + # move + self.assertTrue(self.move_below('Layer 2.C', 'Layer 2.3')) + self.compare_tree_maps() + + # we expect the settings to be carried along from the + # original layer collection + collection_new = self.parse_move('Layer 2.C') + self.assertEqual(collection_new.hide, False) + self.assertEqual(collection_new.hide_select, True) + + +# ############################################################ +# 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_move_above_below_layer_collection_j.py b/tests/python/render_layer/test_move_above_below_layer_collection_j.py new file mode 100644 index 00000000000..6adf134ad34 --- /dev/null +++ b/tests/python/render_layer/test_move_above_below_layer_collection_j.py @@ -0,0 +1,71 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_move_a(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertTrue(self.move_below('Layer 1.3.dog', 'Layer 1.3.cat')) + self.assertTrue(self.move_above('Layer 1.3.dog', 'Layer 1.3.cat')) + self.compare_tree_maps() + + def test_layer_collection_move_b(self): + """ + Test outliner operations + """ + self.setup_tree() + + # collection that will be moved + collection_original = self.parse_move('Layer 1.3.dog') + collection_original.hide = False + collection_original.hide_select = True + + # move + self.assertTrue(self.move_below('Layer 1.3.dog', 'Layer 1.3.cat')) + self.assertTrue(self.move_above('Layer 1.3.dog', 'Layer 1.3.cat')) + self.compare_tree_maps() + + # we expect the settings to be carried along from the + # original layer collection + collection_new = self.parse_move('Layer 1.3.dog') + self.assertEqual(collection_new.hide, False) + self.assertEqual(collection_new.hide_select, True) + + +# ############################################################ +# 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_move_above_below_layer_collection_k.py b/tests/python/render_layer/test_move_above_below_layer_collection_k.py new file mode 100644 index 00000000000..c83731cd001 --- /dev/null +++ b/tests/python/render_layer/test_move_above_below_layer_collection_k.py @@ -0,0 +1,48 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_move(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_below('Layer 2.C.2', 'Layer 2.3')) + self.compare_tree_maps() + + +# ############################################################ +# 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_move_into_layer_collection_a.py b/tests/python/render_layer/test_move_into_layer_collection_a.py new file mode 100644 index 00000000000..37f950a4f15 --- /dev/null +++ b/tests/python/render_layer/test_move_into_layer_collection_a.py @@ -0,0 +1,77 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + reference_tree_map = [ + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ['3', [ + ['dog', None], + ['cat', None], + ]], + ]], + ] + return reference_tree_map + + def get_reference_layers_tree_map(self): + # original tree, no changes + reference_layers_map = [ + ['Layer 1', [ + 'Master Collection', + 'C', + '3', + ]], + ['Layer 2', [ + 'C', + '3', + 'dog', + 'cat', + ]], + ] + return reference_layers_map + + def test_layer_collection_into(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_into("Layer 1.C.2", "Layer 2.3")) + self.compare_tree_maps() + + +# ############################################################ +# 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_move_into_layer_collection_b.py b/tests/python/render_layer/test_move_into_layer_collection_b.py new file mode 100644 index 00000000000..dba8c05e88a --- /dev/null +++ b/tests/python/render_layer/test_move_into_layer_collection_b.py @@ -0,0 +1,48 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_into(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_into('Layer 1.3', 'Layer 1.3.cat')) + self.compare_tree_maps() + + +# ############################################################ +# 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_move_into_layer_collection_c.py b/tests/python/render_layer/test_move_into_layer_collection_c.py new file mode 100644 index 00000000000..32aab1b0da8 --- /dev/null +++ b/tests/python/render_layer/test_move_into_layer_collection_c.py @@ -0,0 +1,48 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_into(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_into("Layer 2.C", "Layer 2.3")) + self.compare_tree_maps() + + +# ############################################################ +# 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_move_into_layer_collection_d.py b/tests/python/render_layer/test_move_into_layer_collection_d.py new file mode 100644 index 00000000000..c43c70afbaf --- /dev/null +++ b/tests/python/render_layer/test_move_into_layer_collection_d.py @@ -0,0 +1,48 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_into(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_into("Layer 2.3.cat", "Layer 2.3")) + self.compare_tree_maps() + + +# ############################################################ +# 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_move_into_layer_collection_e.py b/tests/python/render_layer/test_move_into_layer_collection_e.py new file mode 100644 index 00000000000..ed2d1832efb --- /dev/null +++ b/tests/python/render_layer/test_move_into_layer_collection_e.py @@ -0,0 +1,48 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_into(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_into("Layer 1.Master Collection", "Layer 1.C")) + self.compare_tree_maps() + + +# ############################################################ +# 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_move_into_layer_collection_f.py b/tests/python/render_layer/test_move_into_layer_collection_f.py new file mode 100644 index 00000000000..4e2a3140f4a --- /dev/null +++ b/tests/python/render_layer/test_move_into_layer_collection_f.py @@ -0,0 +1,94 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + reference_tree_map = [ + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ['3', [ + ['dog', None], + ['cat', None], + ]], + ]], + ['B', None], + ['C', [ + ['1', None], + ['2', None], + ]], + ] + return reference_tree_map + + def get_reference_layers_tree_map(self): + reference_layers_map = [ + ['Layer 1', [ + 'Master Collection', + 'C', + ]], + ['Layer 2', [ + 'C', + '3', + 'dog', + 'cat', + ]], + ] + return reference_layers_map + + def test_layer_collection_into_a(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertTrue(self.move_into("Layer 1.3", "Layer 1.Master Collection.A")) + self.compare_tree_maps() + + def test_layer_collection_into_b(self): + """ + Test outliner operations + """ + self.setup_tree() + + # collection that will be moved + collection_original = self.parse_move('Layer 1.3') + collection_original.hide = False + collection_original.hide_select = True + + self.assertTrue(self.move_into('Layer 1.3', 'Layer 1.Master Collection.A')) + self.compare_tree_maps() + + # we expect the settings to be carried along from the + # original layer collection + collection_new = self.parse_move('Layer 1.Master Collection.A.3') + self.assertEqual(collection_new.hide, False) + self.assertEqual(collection_new.hide_select, True) + + +# ############################################################ +# 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_move_into_layer_collection_g.py b/tests/python/render_layer/test_move_into_layer_collection_g.py new file mode 100644 index 00000000000..4afa4cf34e1 --- /dev/null +++ b/tests/python/render_layer/test_move_into_layer_collection_g.py @@ -0,0 +1,85 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + reference_layers_map = [ + ['Layer 1', [ + 'Master Collection', + 'C', + '3', + ]], + ['Layer 2', [ + 'C', + 'dog', + 'cat', + ]], + ] + return reference_layers_map + + def test_layer_collection_into_a(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertTrue(self.move_into('Layer 2.3', 'Layer 2.C')) + self.compare_tree_maps() + + def test_layer_collection_into_b(self): + """ + Test outliner operations + """ + self.setup_tree() + + # collection that will be moved + collection_original = self.parse_move('Layer 2.3') + collection_original.hide = False + collection_original.hide_select = True + + # collection that will disappear + collection_old = self.parse_move('Layer 2.C.3') + collection_old.hide = True + collection_old.hide_select = False + + # move collection + self.assertTrue(self.move_into('Layer 2.3', 'Layer 2.C')) + self.compare_tree_maps() + + # we expect the settings to be carried along from the + # original layer collection + collection_new = self.parse_move('Layer 2.C.3') + self.assertEqual(collection_new.hide, False) + self.assertEqual(collection_new.hide_select, True) + + +# ############################################################ +# 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_move_into_layer_collection_h.py b/tests/python/render_layer/test_move_into_layer_collection_h.py new file mode 100644 index 00000000000..75cee1b3e00 --- /dev/null +++ b/tests/python/render_layer/test_move_into_layer_collection_h.py @@ -0,0 +1,84 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + reference_tree_map = [ + ['A', [ + ['i', None], + ['ii', None], + ['iii', None], + ]], + ['B', None], + ['C', [ + ['1', [ + ['dog', None], + ]], + ['2', None], + ['3', [ + ['cat', None], + ]], + ]], + ] + return reference_tree_map + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_into_a(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertTrue(self.move_into('Layer 1.3.dog', 'Layer 1.C.1')) + self.compare_tree_maps() + + def test_layer_collection_into_b(self): + """ + Test outliner operations + """ + self.setup_tree() + + # collection that will be moved + collection_original = self.parse_move('Layer 1.3.dog') + collection_original.hide = False + collection_original.hide_select = True + + self.assertTrue(self.move_into('Layer 1.3.dog', 'Layer 1.C.1')) + self.compare_tree_maps() + + # we expect the settings to be carried along from the + # original layer collection + collection_new = self.parse_move('Layer 1.C.1.dog') + self.assertEqual(collection_new.hide, False) + self.assertEqual(collection_new.hide_select, True) + + +# ############################################################ +# 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_move_into_layer_collection_i.py b/tests/python/render_layer/test_move_into_layer_collection_i.py new file mode 100644 index 00000000000..46216e8227b --- /dev/null +++ b/tests/python/render_layer/test_move_into_layer_collection_i.py @@ -0,0 +1,48 @@ +# ./blender.bin --background -noaudio --python tests/python/render_layer/test_link.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(MoveLayerCollectionTesting): + def get_reference_scene_tree_map(self): + # original tree, no changes + return self.get_initial_scene_tree_map() + + def get_reference_layers_tree_map(self): + # original tree, no changes + return self.get_initial_layers_tree_map() + + def test_layer_collection_into(self): + """ + Test outliner operations + """ + self.setup_tree() + self.assertFalse(self.move_into('Layer 2.C.3', 'Layer 2.dog')) + self.compare_tree_maps() + + +# ############################################################ +# 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() |