22#include "testing/testing.h"
43 std::unique_ptr<AssetMetaData> dummy_metadata = std::make_unique<AssetMetaData>();
150 b.asset_library_identifier =
"My lib";
162 b.relative_asset_identifier =
"Bar";
182 b.asset_library_identifier =
"My custom lib";
183 b.relative_asset_identifier =
"path/to/an/asset";
194 asset_library_root_);
205 EXPECT_NE(weak_ref, other);
207 EXPECT_NE(weak_ref, other);
218 asset_library_root_);
229 EXPECT_NE(weak_ref, other);
231 EXPECT_NE(weak_ref, other);
256 asset_library_root_);
269 weak_reference__resolve_to_full_path__custom_library__windows_pathsep)
273 asset_library_root_);
295 std::optional<AssetLibraryService::ExplodedPath> resolved_path =
298 EXPECT_EQ(*resolved_path->full_path, expected_full_path);
299 EXPECT_EQ(resolved_path->dir_component,
"");
300 EXPECT_EQ(resolved_path->group_component,
"path");
302 EXPECT_EQ(resolved_path->name_component,
"to/an/asset");
310 asset_library_root_);
316 "/some.blend/Material/") +
318 std::optional<AssetLibraryService::ExplodedPath> resolved_path =
323 std::string(asset_library_root_ +
"/some.blend").c_str()),
325 EXPECT_EQ(resolved_path->group_component,
"Material");
327 EXPECT_EQ(resolved_path->name_component,
"asset/name");
332 weak_reference__resolve_to_exploded_path__custom_library__windows_pathsep)
336 asset_library_root_);
337 AssetRepresentation &asset = add_dummy_asset(*library,
"some.blend\\Material\\asset/name");
342 "\\some.blend\\Material\\") +
344 std::optional<AssetLibraryService::ExplodedPath> resolved_path =
349 std::string(asset_library_root_ +
"\\some.blend").c_str()),
351 EXPECT_EQ(resolved_path->group_component,
"Material");
353 EXPECT_EQ(resolved_path->name_component,
"asset/name");
Main runtime representation of an asset.
IDNewNameResult BKE_id_rename(Main &bmain, ID &id, blender::StringRefNull name, const IDNewNameMode mode=IDNewNameMode::RenameExistingNever)
void * BKE_id_new(Main *bmain, short type, const char *name)
void BKE_main_free(Main *bmain)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
int BLI_path_cmp_normalized(const char *p1, const char *p2) ATTR_NONNULL(1
@ ASSET_LIBRARY_ESSENTIALS
Object is a sort of wrapper for general info.
AssetLibrary * get_asset_library(const Main *bmain, const AssetLibraryReference &library_reference)
std::optional< ExplodedPath > resolve_asset_weak_reference_to_exploded_path(const AssetWeakReference &asset_reference)
std::string resolve_asset_weak_reference_to_full_path(const AssetWeakReference &asset_reference)
static AssetLibraryService * get()
AssetLibrary * get_asset_library_on_disk_custom(StringRef name, StringRefNull root_path)
std::weak_ptr< AssetRepresentation > add_local_id_asset(ID &id)
std::weak_ptr< AssetRepresentation > add_external_asset(StringRef relative_asset_path, StringRef name, int id_type, std::unique_ptr< AssetMetaData > metadata)
StringRefNull library_relative_identifier() const
AssetWeakReference make_weak_reference() const
AssetRepresentation & add_dummy_id_asset(AssetLibrary &library, ID &id)
AssetLibrary * get_builtin_library_from_type(eAssetLibraryType type)
AssetRepresentation & add_dummy_asset(AssetLibrary &library, StringRef relative_path)
TEST_F(AssetCatalogTest, load_single_file)
std::string normalize_path(StringRefNull path, int64_t max_len)
const char * relative_asset_identifier
const char * asset_library_identifier