24#include "testing/testing.h"
45 std::unique_ptr<AssetMetaData> dummy_metadata = std::make_unique<AssetMetaData>();
47 .add_external_on_disk_asset(
48 relative_path,
"Some asset name", 0, std::move(dummy_metadata))
57 return *
library.add_local_id_asset(
id).lock();
153 b.asset_library_identifier =
"My lib";
166 b.relative_asset_identifier =
"Bar";
186 b.asset_library_identifier =
"My custom lib";
187 b.relative_asset_identifier =
"path/to/an/asset";
198 asset_library_root_);
222 asset_library_root_);
260 asset_library_root_);
273 weak_reference__resolve_to_full_path__custom_library__windows_pathsep)
277 asset_library_root_);
299 std::optional<AssetLibraryService::ExplodedPath> resolved_path =
302 EXPECT_EQ(*resolved_path->full_path, expected_full_path);
303 EXPECT_EQ(resolved_path->dir_component,
"");
304 EXPECT_EQ(resolved_path->group_component,
"path");
306 EXPECT_EQ(resolved_path->name_component,
"to/an/asset");
314 asset_library_root_);
320 "/some.blend/Material/") +
322 std::optional<AssetLibraryService::ExplodedPath> resolved_path =
327 std::string(asset_library_root_ +
"/some.blend").c_str()),
329 EXPECT_EQ(resolved_path->group_component,
"Material");
331 EXPECT_EQ(resolved_path->name_component,
"asset/name");
336 weak_reference__resolve_to_exploded_path__custom_library__windows_pathsep)
340 asset_library_root_);
346 "\\some.blend\\Material\\") +
348 std::optional<AssetLibraryService::ExplodedPath> resolved_path =
353 std::string(asset_library_root_ +
"\\some.blend").c_str()),
355 EXPECT_EQ(resolved_path->group_component,
"Material");
357 EXPECT_EQ(resolved_path->name_component,
"asset/name");
Main runtime representation of an asset.
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)
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)
#define EXPECT_NE(result, expect)
TEST_F(AssetCatalogPathTest, construction)
std::string resolve_path(StringRefNull path, int64_t max_len)
@ ASSET_LIBRARY_ESSENTIALS
int BLI_path_cmp_normalized(const char *p1, const char *p2) ATTR_NONNULL(1
void BKE_main_free(Main *bmain)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
IDNewNameResult BKE_id_rename(Main &bmain, ID &id, StringRefNull name, const IDNewNameMode mode=IDNewNameMode::RenameExistingNever)
void * BKE_id_new(Main *bmain, short type, const char *name)
const char * asset_library_identifier
const char * relative_asset_identifier
eAssetLibraryType asset_library_type