Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSybren A. Stüvel <sybren@blender.org>2021-10-18 13:33:53 +0300
committerSybren A. Stüvel <sybren@blender.org>2021-10-18 15:21:41 +0300
commitf9113c4be836691ba599aab9b2f43e26333f8133 (patch)
tree6fa8fc9c1021538478f173e247d932c63929f15b /source/blender/blenkernel/intern/asset_library_test.cc
parent1f510376764debe3e91f736aec6b3af70567243f (diff)
Assets: add global `bke::AssetLibraryService` class
Add `blender::bke::AssetLibraryService` class that acts like a blendfile-scoped singleton. It's allocated upon the first call to `BKE_asset_library_load` and destroyed in the LOAD-PRE handler. The `AssetLibraryService` ensures that edits to asset catalogs are not lost when the asset browser editor closes (or even reloads). Instead, the `AssetLibrary` pointers it owns are kept around as long as the blend file is open. Reviewed By: Severin Maniphest Tasks: T92151 Differential Revision: https://developer.blender.org/D12885
Diffstat (limited to 'source/blender/blenkernel/intern/asset_library_test.cc')
-rw-r--r--source/blender/blenkernel/intern/asset_library_test.cc29
1 files changed, 23 insertions, 6 deletions
diff --git a/source/blender/blenkernel/intern/asset_library_test.cc b/source/blender/blenkernel/intern/asset_library_test.cc
index 30ac4dc6ad8..7c3587c6dfa 100644
--- a/source/blender/blenkernel/intern/asset_library_test.cc
+++ b/source/blender/blenkernel/intern/asset_library_test.cc
@@ -21,11 +21,32 @@
#include "BKE_asset_catalog.hh"
#include "BKE_asset_library.hh"
+#include "asset_library_service.hh"
+
+#include "CLG_log.h"
+
#include "testing/testing.h"
namespace blender::bke::tests {
-TEST(AssetLibraryTest, load_and_free_c_functions)
+class AssetLibraryServiceTest : public testing::Test {
+ public:
+ static void SetUpTestSuite()
+ {
+ CLG_init();
+ }
+ static void TearDownTestSuite()
+ {
+ CLG_exit();
+ }
+
+ void TearDown() override
+ {
+ AssetLibraryService::destroy();
+ }
+};
+
+TEST_F(AssetLibraryServiceTest, bke_asset_library_load)
{
const std::string test_files_dir = blender::tests::flags_test_asset_dir();
if (test_files_dir.empty()) {
@@ -50,11 +71,9 @@ TEST(AssetLibraryTest, load_and_free_c_functions)
AssetCatalog *poses_ellie = service->find_catalog(uuid_poses_ellie);
ASSERT_NE(nullptr, poses_ellie) << "unable to find POSES_ELLIE catalog";
EXPECT_EQ("character/Ellie/poselib", poses_ellie->path.str());
-
- BKE_asset_library_free(library_c_ptr);
}
-TEST(AssetLibraryTest, load_nonexistent_directory)
+TEST_F(AssetLibraryServiceTest, load_nonexistent_directory)
{
const std::string test_files_dir = blender::tests::flags_test_asset_dir();
if (test_files_dir.empty()) {
@@ -75,8 +94,6 @@ TEST(AssetLibraryTest, load_nonexistent_directory)
/* Check that the catalog service doesn't have any catalogs. */
EXPECT_TRUE(service->is_empty());
-
- BKE_asset_library_free(library_c_ptr);
}
} // namespace blender::bke::tests