BigFile/Sasquatch #1
@@ -62,6 +62,13 @@ AssetContainerBase* AssetLibrary::GetAssetContainer(const UUID& p_uuid)
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
bool AssetLibrary::IsLoaded(const UUID& p_uuid) const
|
||||
{
|
||||
return GetAssetContainer(p_uuid) != nullptr;
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
void SetActiveAssetLibrary(AssetLibrary* p_assetLibrary)
|
||||
{
|
||||
g_activeAssetLibrary = p_assetLibrary;
|
||||
|
||||
@@ -81,6 +81,15 @@ class AssetLibrary
|
||||
[[nodiscard]]
|
||||
AssetContainerBase* GetAssetContainer(const UUID& p_uuid);
|
||||
|
||||
/**
|
||||
* Check if an Asset is already loaded in the library
|
||||
*
|
||||
* \param p_uuid The asset to check
|
||||
* \return True if already loaded, false otherwise
|
||||
*/
|
||||
[[nodiscard]]
|
||||
bool IsLoaded(const UUID& p_uuid) const;
|
||||
|
||||
AssetLibrary& operator=(const AssetLibrary& p_library) = default;
|
||||
AssetLibrary& operator=(AssetLibrary&& p_library) = delete;
|
||||
|
||||
|
||||
@@ -99,6 +99,45 @@ TEST_F(AssetLibraryFixture, GetAssetContainer_ShouldReturnNullptrIfNoContainerHa
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(AssetLibraryFixture, IsLoaded_ShouldReturnTrueIfTheAssetIsLoaded)
|
||||
{
|
||||
std::ignore = m_library.Insert(&m_containerA);
|
||||
std::ignore = m_library.Insert(&m_containerB);
|
||||
|
||||
const UUID uuid = m_containerB.Insert()->GetAsset()->GetHeader().uuid;
|
||||
|
||||
EXPECT_TRUE(m_library.IsLoaded(uuid));
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(AssetLibraryFixture, IsLoaded_ShouldReturnFalseIfTheAssetIsNotLoaded)
|
||||
{
|
||||
std::ignore = m_library.Insert(&m_containerA);
|
||||
std::ignore = m_library.Insert(&m_containerB);
|
||||
|
||||
const UUID uuid;
|
||||
|
||||
EXPECT_FALSE(m_library.IsLoaded(uuid));
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(AssetLibraryFixture, IsLoaded_ShouldReturnFalseIfTheAssetWasRemovedFromItsContainer)
|
||||
{
|
||||
std::ignore = m_library.Insert(&m_containerA);
|
||||
std::ignore = m_library.Insert(&m_containerB);
|
||||
|
||||
const UUID uuid = m_containerB.Insert()->GetAsset()->GetHeader().uuid;
|
||||
ASSERT_TRUE(m_library.IsLoaded(uuid));
|
||||
|
||||
m_containerB.Remove(uuid);
|
||||
|
||||
EXPECT_FALSE(m_library.IsLoaded(uuid));
|
||||
}
|
||||
|
||||
/****************************************************************************************/
|
||||
|
||||
TEST_F(AssetLibraryFixture, SetActiveAssetLibrary_ShouldSetTheActiveAssetLibraryToTheGivenLibrary)
|
||||
{
|
||||
SetActiveAssetLibrary(&m_library);
|
||||
|
||||
Reference in New Issue
Block a user