[Bf-blender-cvs] [58d32e81852] blender-projects-basics: Merge branch 'master' into blender-projects-basics
Julian Eisel
noreply at git.blender.org
Fri Jan 6 17:20:52 CET 2023
Commit: 58d32e81852bca52fe7804d359a625bda54c22e0
Author: Julian Eisel
Date: Fri Jan 6 15:26:21 2023 +0100
Branches: blender-projects-basics
https://developer.blender.org/rB58d32e81852bca52fe7804d359a625bda54c22e0
Merge branch 'master' into blender-projects-basics
===================================================================
===================================================================
diff --cc release/scripts/startup/bl_ui/space_userpref.py
index 7223c750f32,e58302fde06..dde39529df4
--- a/release/scripts/startup/bl_ui/space_userpref.py
+++ b/release/scripts/startup/bl_ui/space_userpref.py
@@@ -2288,8 -2339,6 +2310,7 @@@ class USERPREF_PT_experimental_prototyp
({"property": "use_sculpt_texture_paint"}, "T96225"),
({"property": "use_full_frame_compositor"}, "T88150"),
({"property": "enable_eevee_next"}, "T93220"),
- ({"property": "use_draw_manager_acquire_lock"}, "T98016"),
+ ({"property": "use_blender_projects"}, None),
),
)
diff --cc source/blender/asset_system/tests/asset_catalog_test.cc
index 00000000000,3e117e3da97..8e4b47bc40a
mode 000000,100644..100644
--- a/source/blender/asset_system/tests/asset_catalog_test.cc
+++ b/source/blender/asset_system/tests/asset_catalog_test.cc
@@@ -1,0 -1,1277 +1,1277 @@@
+ /* SPDX-License-Identifier: GPL-2.0-or-later
+ * Copyright 2020 Blender Foundation. All rights reserved. */
+
+ #include "AS_asset_catalog.hh"
+ #include "AS_asset_catalog_tree.hh"
+
-#include "BKE_preferences.h"
++#include "BKE_asset_library_custom.h"
+
+ #include "BLI_fileops.h"
+ #include "BLI_path_util.h"
+
+ #include "DNA_asset_types.h"
+ #include "DNA_userdef_types.h"
+
+ #include "testing/testing.h"
+
+ #include "asset_library_test_common.hh"
+
+ namespace blender::asset_system::tests {
+
+ /* UUIDs from lib/tests/asset_library/blender_assets.cats.txt */
+ const bUUID UUID_ID_WITHOUT_PATH("e34dd2c5-5d2e-4668-9794-1db5de2a4f71");
+ const bUUID UUID_POSES_ELLIE("df60e1f6-2259-475b-93d9-69a1b4a8db78");
+ const bUUID UUID_POSES_ELLIE_WHITESPACE("b06132f6-5687-4751-a6dd-392740eb3c46");
+ const bUUID UUID_POSES_ELLIE_TRAILING_SLASH("3376b94b-a28d-4d05-86c1-bf30b937130d");
+ const bUUID UUID_POSES_ELLIE_BACKSLASHES("a51e17ae-34fc-47d5-ba0f-64c2c9b771f7");
+ const bUUID UUID_POSES_RUZENA("79a4f887-ab60-4bd4-94da-d572e27d6aed");
+ const bUUID UUID_POSES_RUZENA_HAND("81811c31-1a88-4bd7-bb34-c6fc2607a12e");
+ const bUUID UUID_POSES_RUZENA_FACE("82162c1f-06cc-4d91-a9bf-4f72c104e348");
+ const bUUID UUID_WITHOUT_SIMPLENAME("d7916a31-6ca9-4909-955f-182ca2b81fa3");
+ const bUUID UUID_ANOTHER_RUZENA("00000000-d9fa-4b91-b704-e6af1f1339ef");
+
+ /* UUIDs from lib/tests/asset_library/modified_assets.cats.txt */
+ const bUUID UUID_AGENT_47("c5744ba5-43f5-4f73-8e52-010ad4a61b34");
+
+ /* Subclass that adds accessors such that protected fields can be used in tests. */
+ class TestableAssetCatalogService : public AssetCatalogService {
+ public:
+ TestableAssetCatalogService() = default;
+
+ explicit TestableAssetCatalogService(const CatalogFilePath &asset_library_root)
+ : AssetCatalogService(asset_library_root)
+ {
+ }
+
+ AssetCatalogDefinitionFile *get_catalog_definition_file()
+ {
+ return AssetCatalogService::get_catalog_definition_file();
+ }
+
+ OwningAssetCatalogMap &get_deleted_catalogs()
+ {
+ return AssetCatalogService::get_deleted_catalogs();
+ }
+
+ void create_missing_catalogs()
+ {
+ AssetCatalogService::create_missing_catalogs();
+ }
+
+ void delete_catalog_by_id_soft(CatalogID catalog_id)
+ {
+ AssetCatalogService::delete_catalog_by_id_soft(catalog_id);
+ }
+
+ int64_t count_catalogs_with_path(const CatalogFilePath &path)
+ {
+ int64_t count = 0;
+ for (auto &catalog_uptr : get_catalogs().values()) {
+ if (catalog_uptr->path == path) {
+ count++;
+ }
+ }
+ return count;
+ }
+ };
+
+ class AssetCatalogTest : public AssetLibraryTestBase {
+ protected:
+ /* Used by on_blendfile_save__from_memory_into_existing_asset_lib* test functions. */
+ void save_from_memory_into_existing_asset_lib(const bool should_top_level_cdf_exist)
+ {
+ const CatalogFilePath target_dir = create_temp_path(); /* Has trailing slash. */
+ const CatalogFilePath original_cdf_file = asset_library_root_ + SEP_STR +
+ "blender_assets.cats.txt";
+ const CatalogFilePath registered_asset_lib = target_dir + "my_asset_library" + SEP_STR;
+ const CatalogFilePath asset_lib_subdir = registered_asset_lib + "subdir" + SEP_STR;
+ CatalogFilePath cdf_toplevel = registered_asset_lib +
+ AssetCatalogService::DEFAULT_CATALOG_FILENAME;
+ CatalogFilePath cdf_in_subdir = asset_lib_subdir +
+ AssetCatalogService::DEFAULT_CATALOG_FILENAME;
+ BLI_path_slash_native(cdf_toplevel.data());
+ BLI_path_slash_native(cdf_in_subdir.data());
+
+ /* Set up a temporary asset library for testing. */
- bUserAssetLibrary *asset_lib_pref = BKE_preferences_asset_library_add(
- &U, "Test", registered_asset_lib.c_str());
++ CustomAssetLibraryDefinition *asset_lib_pref = BKE_asset_library_custom_add(
++ &U.asset_libraries, "Test", registered_asset_lib.c_str());
+ ASSERT_NE(nullptr, asset_lib_pref);
+ ASSERT_TRUE(BLI_dir_create_recursive(asset_lib_subdir.c_str()));
+
+ if (should_top_level_cdf_exist) {
+ ASSERT_EQ(0, BLI_copy(original_cdf_file.c_str(), cdf_toplevel.c_str()));
+ }
+
+ /* Create an empty CDF to add complexity. It should not save to this, but to the top-level
+ * one. */
+ ASSERT_TRUE(BLI_file_touch(cdf_in_subdir.c_str()));
+ ASSERT_EQ(0, BLI_file_size(cdf_in_subdir.c_str()));
+
+ /* Create the catalog service without loading the already-existing CDF. */
+ TestableAssetCatalogService service;
+ const CatalogFilePath blendfilename = asset_lib_subdir + "some_file.blend";
+ const AssetCatalog *cat = service.create_catalog("some/catalog/path");
+
+ /* Mock that the blend file is written to the directory already containing a CDF. */
+ ASSERT_TRUE(service.write_to_disk(blendfilename));
+
+ /* Test that the CDF still exists in the expected location. */
+ EXPECT_TRUE(BLI_exists(cdf_toplevel.c_str()));
+ const CatalogFilePath backup_filename = cdf_toplevel + "~";
+ const bool backup_exists = BLI_exists(backup_filename.c_str());
+ EXPECT_EQ(should_top_level_cdf_exist, backup_exists)
+ << "Overwritten CDF should have been backed up.";
+
+ /* Test that the in-memory CDF has the expected file path. */
+ AssetCatalogDefinitionFile *cdf = service.get_catalog_definition_file();
+ BLI_path_slash_native(cdf->file_path.data());
+ EXPECT_EQ(cdf_toplevel, cdf->file_path);
+
+ /* Test that the in-memory catalogs have been merged with the on-disk one. */
+ AssetCatalogService loaded_service(cdf_toplevel);
+ loaded_service.load_from_disk();
+ EXPECT_NE(nullptr, loaded_service.find_catalog(cat->catalog_id));
+
+ /* This catalog comes from a pre-existing CDF that should have been merged.
+ * However, if the file doesn't exist, so does the catalog. */
+ AssetCatalog *poses_ellie_catalog = loaded_service.find_catalog(UUID_POSES_ELLIE);
+ if (should_top_level_cdf_exist) {
+ EXPECT_NE(nullptr, poses_ellie_catalog);
+ }
+ else {
+ EXPECT_EQ(nullptr, poses_ellie_catalog);
+ }
+
+ /* Test that the "red herring" CDF has not been touched. */
+ EXPECT_EQ(0, BLI_file_size(cdf_in_subdir.c_str()));
+
- BKE_preferences_asset_library_remove(&U, asset_lib_pref);
++ BKE_asset_library_custom_remove(&U.asset_libraries, asset_lib_pref);
+ }
+ };
+
+ TEST_F(AssetCatalogTest, load_single_file)
+ {
+ AssetCatalogService service(asset_library_root_);
+ service.load_from_disk(asset_library_root_ + SEP_STR + "blender_assets.cats.txt");
+
+ /* Test getting a non-existent catalog ID. */
+ EXPECT_EQ(nullptr, service.find_catalog(BLI_uuid_generate_random()));
+
+ /* Test getting an invalid catalog (without path definition). */
+ AssetCatalog *cat_without_path = service.find_catalog(UUID_ID_WITHOUT_PATH);
+ ASSERT_EQ(nullptr, cat_without_path);
+
+ /* Test getting a regular catalog. */
+ AssetCatalog *poses_ellie = service.find_catalog(UUID_POSES_ELLIE);
+ ASSERT_NE(nullptr, poses_ellie);
+ EXPECT_EQ(UUID_POSES_ELLIE, poses_ellie->catalog_id);
+ EXPECT_EQ("character/Ellie/poselib", poses_ellie->path.str());
+ EXPECT_EQ("POSES_ELLIE", poses_ellie->simple_name);
+
+ /* Test white-space stripping and support in the path. */
+ AssetCatalog *poses_whitespace = service.find_catalog(UUID_POSES_ELLIE_WHITESPACE);
+ ASSERT_NE(nullptr, poses_whitespace);
+ EXPECT_EQ(UUID_POSES_ELLIE_WHITESPACE, poses_whitespace->catalog_id);
+ EXPECT_EQ("character/Ellie/poselib/white space", poses_whitespace->path.str());
+ EXPECT_EQ("POSES_ELLIE WHITESPACE", poses_whitespace->simple_name);
+
+ /* Test getting a UTF-8 catalog ID. */
+ AssetCatalog *poses_ruzena = service.find_catalog(UUID_POSES_RUZENA);
+ ASSERT_NE(nullptr, poses_ruzena);
+ EXPECT_EQ(UUID_POSES_RUZENA, poses_ruzena->catalog_id);
+ EXPECT_EQ("character/Ružena/poselib", poses_ruzena->path.str());
+ EXPECT_EQ("POSES_RUŽENA", poses_ruzena->simple_name);
+
+ /* Test getting a catalog that aliases an earlier-defined catalog. */
+ AssetCatalog *another_ruzena = service.find_catalog(UUID_ANOTHER_RUZENA);
+ ASSERT_NE(nullptr, another_ruzena);
+ EXPECT_EQ(UUID_ANOTHER_RUZENA, another_ruzena->catalog_id);
+ EXPECT_EQ("character/Ružena/poselib", another_ruzena->path.str());
+ EXPECT_EQ("Another Ružena", another_ruzena->simple_name);
+ }
+
+ TEST_F(AssetCatalogTest, load_catalog_path_backslashes)
+ {
+ AssetCatalogService service(asset_library_root_);
+ service.load_from_disk(asset_library_root_ + SEP_STR + "blender_assets.cats.txt");
+
+ const AssetCatalog *found_by_id = service.find_catalog(UUID_POSES_ELLIE_BACKSLASHES);
+ ASSERT_NE(nullptr, found_by_id);
+ EXPECT_EQ(AssetCatalogPath("character/Ellie/backslashes"), found_by_id->path)
+ << "Backslashes should be normalized when loading from disk.";
+ EXPECT_EQ(StringRefNull("Windows For Life!"), found_by_id->simple_name);
+
+ const AssetCatalog *found_by_path = service.find_catalog_by_path("character/Ellie/backslashes");
+ EXPECT_EQ(found_by_id, found_by_path)
+ <<
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list