19#include "testing/testing.h"
43 const std::string test_files_dir = blender::tests::flags_test_asset_dir();
44 if (test_files_dir.empty()) {
83 <<
"Calling twice without destroying in between should return the same instance.";
103 <<
"Calling twice without destroying in between should return the same instance.";
105 <<
"Calling twice without destroying in between should return the same instance.";
121 <<
"Getting the local (current file) reference without a main saved on disk should return "
122 "the current file library";
126 std::string dummy_filepath = asset_library_root_ +
SEP +
"dummy.blend";
127 STRNCPY(dummy_main.filepath, dummy_filepath.c_str());
130 asset_library_root_);
137 EXPECT_NE(custom_lib, tmp_curfile_lib)
138 <<
"Getting an asset library from a local (current file) library reference should never "
139 "match any custom asset library";
149 char asset_lib_with_slash[
PATH_MAX];
150 STRNCPY(asset_lib_no_slash, asset_library_root_.c_str());
151 STRNCPY(asset_lib_with_slash, asset_library_root_.c_str());
155 while (strlen(asset_lib_no_slash) &&
156 ELEM(asset_lib_no_slash[strlen(asset_lib_no_slash) - 1],
SEP,
ALTSEP))
158 asset_lib_no_slash[strlen(asset_lib_no_slash) - 1] =
'\0';
168 <<
"With or without trailing slash shouldn't matter.";
175 asset_library_root_);
180 <<
"Catalogs should be loaded after getting an asset library from disk.";
187 <<
"Empty AssetLibraryService should have no unsaved catalogs";
190 asset_library_root_);
193 <<
"Unchanged AssetLibrary should have no unsaved catalogs";
198 <<
"Deletion of catalogs via AssetCatalogService should not automatically tag as 'unsaved "
203 ASSERT_NE(
nullptr, cat) <<
"Catalog " <<
UUID_POSES_RUZENA <<
" should be known";
207 <<
"Tagging as having unsaved changes of a single catalog service should result in unsaved "
208 "changes being reported.";
216 "blender_assets.cats.txt";
219 ASSERT_EQ(0,
BLI_copy(original_cdf_file.c_str(), writable_cdf_file.c_str()));
225 <<
"Unchanged AssetLibrary should have no unsaved catalogs";
233 <<
"Tagging as having unsaved changes of a single catalog service should result in unsaved "
234 "changes being reported.";
237 cat_service.
write_to_disk(writable_dir +
"dummy_path.blend");
239 <<
"Written AssetCatalogService should have no unsaved catalogs";
void BKE_tempdir_init(const char *userdir)
void BKE_callback_global_finalize()
void BKE_callback_global_init()
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
File and directory operations.
int BLI_copy(const char *path_src, const char *path_dst) ATTR_NONNULL()
bool BLI_dir_create_recursive(const char *dirname) ATTR_NONNULL()
int BLI_delete(const char *path, bool dir, bool recursive) ATTR_NONNULL()
void BLI_path_slash_native(char *path) ATTR_NONNULL(1)
int BLI_path_slash_ensure(char *path, size_t path_maxncpy) ATTR_NONNULL(1)
#define STRNCPY(dst, src)
AssetCatalog * find_catalog(CatalogID catalog_id) const
bool write_to_disk(const CatalogFilePath &blend_file_path)
void prune_catalogs_by_id(CatalogID catalog_id)
static const CatalogFilePath DEFAULT_CATALOG_FILENAME
void tag_has_unsaved_changes(AssetCatalog *edited_catalog)
struct blender::asset_system::AssetCatalog::Flags flags
AssetLibrary * get_asset_library(const Main *bmain, const AssetLibraryReference &library_reference)
AssetLibrary * get_asset_library_current_file()
static AssetLibraryService * get()
AssetLibrary * get_asset_library_on_disk_custom(StringRef name, StringRefNull root_path)
bool has_any_unsaved_catalogs() const
StringRefNull root_path() const
CatalogFilePath create_temp_path()
static void SetUpTestSuite()
CatalogFilePath use_temp_path()
static void TearDownTestSuite()
CatalogFilePath temp_library_path_
CatalogFilePath asset_library_root_
TEST_F(AssetCatalogTest, load_single_file)
const bUUID UUID_POSES_ELLIE("df60e1f6-2259-475b-93d9-69a1b4a8db78")
const bUUID UUID_POSES_RUZENA("79a4f887-ab60-4bd4-94da-d572e27d6aed")
std::string CatalogFilePath
Universally Unique Identifier according to RFC4122.
void * BKE_tempdir_session
static DynamicLibrary lib