[Bf-blender-cvs] [ba5a01bff13] sybren-usd: USD: updated GTest to use the BlendfileLoadingBaseTest introduced in D6246
Sybren A. Stüvel
noreply at git.blender.org
Thu Nov 21 10:36:23 CET 2019
Commit: ba5a01bff135007af504e18eb5597b9ab64bd307
Author: Sybren A. Stüvel
Date: Thu Nov 21 10:35:49 2019 +0100
Branches: sybren-usd
https://developer.blender.org/rBba5a01bff135007af504e18eb5597b9ab64bd307
USD: updated GTest to use the BlendfileLoadingBaseTest introduced in D6246
===================================================================
M tests/gtests/usd/CMakeLists.txt
M tests/gtests/usd/abstract_hierarchy_iterator_test.cc
D tests/gtests/usd/blendfile_loading_test.cc
D tests/gtests/usd/blendfile_loading_test.h
===================================================================
diff --git a/tests/gtests/usd/CMakeLists.txt b/tests/gtests/usd/CMakeLists.txt
index 5c17674219c..787420639de 100644
--- a/tests/gtests/usd/CMakeLists.txt
+++ b/tests/gtests/usd/CMakeLists.txt
@@ -31,11 +31,11 @@ set(INC
../../../intern/guardedalloc
${USD_INCLUDE_DIRS}
${BOOST_INCLUDE_DIR}
- ${HDF5_INCLUDE_DIRS}
${OPENEXR_INCLUDE_DIRS}
)
set(LIB
+ bf_blenloader_test
bf_blenloader
bf_intern_opencolorio # Should not be needed but gives windows linker errors if the ocio libs are linked before this
bf_gpu # Should not be needed but gives windows linker errors if the ocio libs are linked before this
@@ -53,12 +53,11 @@ else()
set(_buildinfo_src "")
endif()
-BLENDER_SRC_GTEST_EX(usd "blendfile_loading_test.cc;abstract_hierarchy_iterator_test.cc;${_buildinfo_src}" "${LIB}" "FALSE")
-add_test(
- NAME usd_test
- COMMAND ${TESTS_OUTPUT_DIR}/usd_test --test-assets-dir ${CMAKE_SOURCE_DIR}/../lib/tests
- WORKING_DIRECTORY ${TEST_INSTALL_DIR})
-
+BLENDER_SRC_GTEST_EX(
+ NAME usd
+ SRC "abstract_hierarchy_iterator_test.cc;${_buildinfo_src}"
+ EXTRA_LIBS "${LIB}"
+ COMMAND_ARGS --test-assets-dir "${CMAKE_SOURCE_DIR}/../lib/tests")
unset(_buildinfo_src)
diff --git a/tests/gtests/usd/abstract_hierarchy_iterator_test.cc b/tests/gtests/usd/abstract_hierarchy_iterator_test.cc
index 27666803ce9..6aeba40bb8f 100644
--- a/tests/gtests/usd/abstract_hierarchy_iterator_test.cc
+++ b/tests/gtests/usd/abstract_hierarchy_iterator_test.cc
@@ -1,4 +1,4 @@
-#include "blendfile_loading_test.h"
+#include "blenloader/blendfile_loading_base_test.h"
#include "intern/abstract_hierarchy_iterator.h"
extern "C" {
@@ -82,20 +82,20 @@ class TestingHierarchyIterator : public AbstractHierarchyIterator {
}
};
-class USDHierarchyIteratorTest : public BlendfileLoadingTest {
+class USDHierarchyIteratorTest : public BlendfileLoadingBaseTest {
protected:
TestingHierarchyIterator *iterator;
virtual void SetUp()
{
- BlendfileLoadingTest::SetUp();
+ BlendfileLoadingBaseTest::SetUp();
iterator = nullptr;
}
virtual void TearDown()
{
iterator_free();
- BlendfileLoadingTest::TearDown();
+ BlendfileLoadingBaseTest::TearDown();
}
/* Create a test iterator. */
diff --git a/tests/gtests/usd/blendfile_loading_test.cc b/tests/gtests/usd/blendfile_loading_test.cc
deleted file mode 100644
index c6c9d56678e..00000000000
--- a/tests/gtests/usd/blendfile_loading_test.cc
+++ /dev/null
@@ -1,102 +0,0 @@
-#include "blendfile_loading_test.h"
-
-extern "C" {
-#include "BKE_main.h"
-#include "BKE_node.h"
-#include "BKE_scene.h"
-
-#include "BLI_path_util.h"
-
-#include "BLO_readfile.h"
-
-#include "DEG_depsgraph_build.h"
-#include "DEG_depsgraph.h"
-
-#include "DNA_genfile.h" /* for DNA_sdna_current_init() */
-#include "DNA_windowmanager_types.h"
-
-#include "MEM_guardedalloc.h"
-
-#include "RNA_define.h"
-}
-
-DEFINE_string(test_assets_dir,
- "../../lib/tests",
- "lib/tests directory from SVN, containing the test assets.");
-
-BlendfileLoadingTest::BlendfileLoadingTest() : testing::Test(), bfile(nullptr), depsgraph(nullptr)
-{
-}
-
-BlendfileLoadingTest::~BlendfileLoadingTest()
-{
-}
-
-void BlendfileLoadingTest::SetUp()
-{
- testing::Test::SetUp();
-
- /* Minimal code to make loading a blendfile and constructing a depsgraph not crash, copied from
- * main() in creator.c. */
- DNA_sdna_current_init();
- DEG_register_node_types();
- RNA_init();
- init_nodesystem();
-}
-
-void BlendfileLoadingTest::TearDown()
-{
- depsgraph_free();
- blendfile_free();
-
- testing::Test::TearDown();
-}
-
-bool BlendfileLoadingTest::blendfile_load(const char *filepath)
-{
- const char *test_assets_dir = FLAGS_test_assets_dir.c_str();
- if (test_assets_dir == nullptr || test_assets_dir[0] == '\0') {
- ADD_FAILURE()
- << "Pass the flag --test_assets_dir and point to the lib/tests directory from SVN.";
- return false;
- }
-
- char abspath[FILENAME_MAX];
- BLI_path_join(abspath, sizeof(abspath), test_assets_dir, filepath, NULL);
-
- bfile = BLO_read_from_file(abspath, BLO_READ_SKIP_NONE, NULL /* reports */);
- if (bfile == nullptr) {
- ADD_FAILURE();
- return false;
- }
-
- /* Create a dummy window manager. Some code would SEGFAULT without it. */
- bfile->main->wm.first = MEM_callocN(sizeof(wmWindowManager), "Dummy Window Manager");
- return true;
-}
-
-void BlendfileLoadingTest::blendfile_free()
-{
- if (bfile == nullptr) {
- return;
- }
- BLO_blendfiledata_free(bfile);
- bfile = nullptr;
-}
-
-void BlendfileLoadingTest::depsgraph_create(eEvaluationMode depsgraph_evaluation_mode)
-{
- depsgraph = DEG_graph_new(
- bfile->main, bfile->curscene, bfile->cur_view_layer, depsgraph_evaluation_mode);
- DEG_graph_build_from_view_layer(depsgraph, bfile->main, bfile->curscene, bfile->cur_view_layer);
- BKE_scene_graph_update_tagged(depsgraph, bfile->main);
-}
-
-void BlendfileLoadingTest::depsgraph_free()
-{
- if (depsgraph == nullptr) {
- return;
- }
- DEG_graph_free(depsgraph);
- depsgraph = nullptr;
-}
diff --git a/tests/gtests/usd/blendfile_loading_test.h b/tests/gtests/usd/blendfile_loading_test.h
deleted file mode 100644
index e4db06673b2..00000000000
--- a/tests/gtests/usd/blendfile_loading_test.h
+++ /dev/null
@@ -1,37 +0,0 @@
-#ifndef __BLENDFILE_LOADING_TEST_H__
-#define __BLENDFILE_LOADING_TEST_H__
-
-#include "testing/testing.h"
-#include <DEG_depsgraph.h>
-
-struct BlendFileData;
-struct Depsgraph;
-
-class BlendfileLoadingTest : public testing::Test {
- protected:
- struct BlendFileData *bfile;
- struct Depsgraph *depsgraph;
-
- public:
- BlendfileLoadingTest();
- virtual ~BlendfileLoadingTest();
-
- virtual void SetUp();
- virtual void TearDown();
-
- protected:
- /* Load a blend file, return 'ok' (true=good, false=bad) and set bfile.
- * Fails the test if the file cannot be loaded (still returns though).
- * Requires the environment variable TEST_ASSETS_DIR to point to ../lib/tests.
- */
- bool blendfile_load(const char *filepath);
- /* Free bfile if it is not nullptr */
- void blendfile_free();
-
- /* Create a depsgraph. Assumes a blend file has been loaded. */
- void depsgraph_create(eEvaluationMode depsgraph_evaluation_mode);
- /* Free the depsgraph if it's not nullptr. */
- void depsgraph_free();
-};
-
-#endif /* __BLENDFILE_LOADING_TEST_H__ */
More information about the Bf-blender-cvs
mailing list