diff options
-rw-r--r-- | source/blender/blenloader/tests/blendfile_loading_base_test.h | 4 | ||||
-rw-r--r-- | source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc | 50 |
2 files changed, 49 insertions, 5 deletions
diff --git a/source/blender/blenloader/tests/blendfile_loading_base_test.h b/source/blender/blenloader/tests/blendfile_loading_base_test.h index a5e75ef6df8..f90e07218fb 100644 --- a/source/blender/blenloader/tests/blendfile_loading_base_test.h +++ b/source/blender/blenloader/tests/blendfile_loading_base_test.h @@ -56,9 +56,9 @@ class BlendfileLoadingBaseTest : public testing::Test { void blendfile_free(); /* Create a depsgraph. Assumes a blend file has been loaded to this->bfile. */ - void depsgraph_create(eEvaluationMode depsgraph_evaluation_mode); + virtual void depsgraph_create(eEvaluationMode depsgraph_evaluation_mode); /* Free the depsgraph if it's not nullptr. */ - void depsgraph_free(); + virtual void depsgraph_free(); }; #endif /* __BLENDFILE_LOADING_BASE_TEST_H__ */ diff --git a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc index cbb2e63a99f..57bc68d25bf 100644 --- a/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc +++ b/source/blender/io/common/intern/abstract_hierarchy_iterator_test.cc @@ -20,8 +20,11 @@ #include "tests/blendfile_loading_base_test.h" +#include "BKE_scene.h" #include "BLI_math.h" +#include "BLO_readfile.h" #include "DEG_depsgraph.h" +#include "DEG_depsgraph_build.h" #include "DNA_object_types.h" #include <map> @@ -99,7 +102,7 @@ class TestingHierarchyIterator : public AbstractHierarchyIterator { } }; -class USDHierarchyIteratorTest : public BlendfileLoadingBaseTest { +class AbstractHierarchyIteratorTest : public BlendfileLoadingBaseTest { protected: TestingHierarchyIterator *iterator; @@ -131,7 +134,7 @@ class USDHierarchyIteratorTest : public BlendfileLoadingBaseTest { } }; -TEST_F(USDHierarchyIteratorTest, ExportHierarchyTest) +TEST_F(AbstractHierarchyIteratorTest, ExportHierarchyTest) { /* Load the test blend file. */ if (!blendfile_load("usd/usd_hierarchy_export_test.blend")) { @@ -206,7 +209,7 @@ TEST_F(USDHierarchyIteratorTest, ExportHierarchyTest) EXPECT_EQ(expected_data, iterator->data_writers); } -TEST_F(USDHierarchyIteratorTest, ExportSubsetTest) +TEST_F(AbstractHierarchyIteratorTest, ExportSubsetTest) { // The scene has no hair or particle systems, and this is already covered by ExportHierarchyTest, // so not included here. Update this test when hair & particle systems are included. @@ -317,4 +320,45 @@ TEST_F(USDHierarchyIteratorTest, ExportSubsetTest) EXPECT_EQ(expected_transforms, iterator->transform_writers); EXPECT_EQ(expected_data, iterator->data_writers); } + +/* Test class that constructs a depsgraph in such a way that it includes invisible objects. */ +class AbstractHierarchyIteratorInvisibleTest : public AbstractHierarchyIteratorTest { + protected: + void depsgraph_create(eEvaluationMode depsgraph_evaluation_mode) override + { + depsgraph = DEG_graph_new( + bfile->main, bfile->curscene, bfile->cur_view_layer, depsgraph_evaluation_mode); + DEG_graph_build_for_all_objects( + depsgraph, bfile->main, bfile->curscene, bfile->cur_view_layer); + BKE_scene_graph_update_tagged(depsgraph, bfile->main); + } +}; + +TEST_F(AbstractHierarchyIteratorInvisibleTest, ExportInvisibleTest) +{ + if (!blendfile_load("alembic/visibility.blend")) { + return; + } + depsgraph_create(DAG_EVAL_RENDER); + iterator_create(); + + iterator->iterate_and_write(); + + // Mapping from object name to set of export paths. + used_writers expected_transforms = {{"OBInvisibleAnimatedCube", {"/InvisibleAnimatedCube"}}, + {"OBInvisibleCube", {"/InvisibleCube"}}, + {"OBVisibleCube", {"/VisibleCube"}}}; + EXPECT_EQ(expected_transforms, iterator->transform_writers); + + used_writers expected_data = {{"OBInvisibleAnimatedCube", {"/InvisibleAnimatedCube/Cube"}}, + {"OBInvisibleCube", {"/InvisibleCube/Cube"}}, + {"OBVisibleCube", {"/VisibleCube/Cube"}}}; + + EXPECT_EQ(expected_data, iterator->data_writers); + + // The scene has no hair or particle systems. + EXPECT_EQ(0, iterator->hair_writers.size()); + EXPECT_EQ(0, iterator->particle_writers.size()); +} + } // namespace blender::io |