627012840d
* Fixed the return value of the ConvertToAbsolutePath function Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Added the generated cmake_dependencies.*.setreg files to engine.pak (#5073) * Copied the generated cmake_dependencies.*.setreg file to the Cache directory Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Removed the platform name from the bootstrap.game.*.setreg Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Update how the project related file paths are determined when not supplied. The project-path determination now goes back to only detecting a "project.json" file. It no longer attempts to detect a "Cache" directory The project-cache-path determination now in addition to checking the project_cache_path key searches for a "Cache" directory. The project-path defaults to executable folder if it cannot be detected. The copying of generated executable folder Registry directory contents to the product cache is now removed after the archive step. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated the invocation of the AssetProcessor in Jenkins to supply an absolute path to the project. The project-path is no longer treated as relative to the engine root, but instead relative to the current working directory at application startup. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Added constant for the storing the name of Cache directory Fixed typos and grammatical errors in the SettingsRegistryMergeUtils.cpp Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Updated UnitTest prepend the EngineRoot path to "AutomatedTesting" when setting the project path. This is needed now that the project-path isn't treated relative to the EngineRoot if it is not absolute. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Fix AssetSeedManagerTest and PlatformAddressedAssetCatalogManagerTest Instead of trying to used the AutomatedTesting directory as the project root, the temp directory created during the test is used as the project root. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Moved the setting of the project cache root folder and project asset platform root folder into the `if (!projectCachePath.empty())` block Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com> * Removing the scan up logic for the "Cache" directory. This is no longer needed to locate the project cache path in a Project Game Release Layout. Because the project path defaults to the executable directory if, it is not found, the Cache directory will be set to the "Cache" directory within the executable directory. Signed-off-by: lumberyard-employee-dm <56135373+lumberyard-employee-dm@users.noreply.github.com>
204 lines
6.4 KiB
C++
204 lines
6.4 KiB
C++
/*
|
|
* Copyright (c) Contributors to the Open 3D Engine Project.
|
|
* For complete copyright and license terms please see the LICENSE at the root of this distribution.
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 OR MIT
|
|
*
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <AzTest/AzTest.h>
|
|
#include <AssetValidationSystemComponent.h>
|
|
|
|
#include <AzFramework/API/ApplicationAPI.h>
|
|
#include <AzFramework/Asset/AssetSeedList.h>
|
|
#include <AzFramework/Asset/AssetSystemBus.h>
|
|
#include <AzFramework/IO/LocalFileIO.h>
|
|
#include <AzCore/UnitTest/TestTypes.h>
|
|
#include <AzCore/Settings/SettingsRegistryImpl.h>
|
|
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
|
#include <Tests/FileIOBaseTestTypes.h>
|
|
#include <Utils/Utils.h>
|
|
|
|
constexpr int NumTestAssets = 10;
|
|
constexpr char ProjectName[] = "UnitTest";
|
|
|
|
class MockValidationComponent : public AssetValidation::AssetValidationSystemComponent
|
|
, public AZ::Data::AssetCatalogRequestBus::Handler
|
|
{
|
|
public:
|
|
|
|
MockValidationComponent()
|
|
{
|
|
for (int i = 0; i < NumTestAssets; ++i)
|
|
{
|
|
m_assetIds[i] = AZ::Data::AssetId(AZ::Uuid::CreateRandom(), 0);
|
|
}
|
|
AZ::Data::AssetCatalogRequestBus::Handler::BusConnect();
|
|
AssetValidation::AssetValidationSystemComponent::Activate();
|
|
}
|
|
|
|
~MockValidationComponent()
|
|
{
|
|
AssetValidation::AssetValidationSystemComponent::Deactivate();
|
|
AZ::Data::AssetCatalogRequestBus::Handler::BusDisconnect();
|
|
}
|
|
|
|
void SeedMode() override
|
|
{
|
|
AssetValidation::AssetValidationSystemComponent::SeedMode();
|
|
}
|
|
|
|
bool IsKnownAsset(const char* fileName) override
|
|
{
|
|
return AssetValidation::AssetValidationSystemComponent::IsKnownAsset(fileName);
|
|
}
|
|
|
|
bool AddSeedAssetId(AZ::Data::AssetId assetId, AZ::u32 sourceId) override
|
|
{
|
|
return AssetValidation::AssetValidationSystemComponent::AddSeedAssetId(assetId, sourceId);
|
|
}
|
|
|
|
AZ::Data::AssetInfo GetAssetInfoById(const AZ::Data::AssetId& id) override
|
|
{
|
|
AZ::Data::AssetInfo result;
|
|
|
|
for (int slotNum = 0; slotNum < NumTestAssets; ++slotNum)
|
|
{
|
|
const AZ::Data::AssetId& assetId = m_assetIds[slotNum];
|
|
if (assetId == id)
|
|
{
|
|
result.m_assetId = id;
|
|
// Internal paths should be lower cased as from the cache
|
|
result.m_relativePath = AZStd::string::format("assetpath%d", slotNum);
|
|
break;
|
|
}
|
|
}
|
|
return result;
|
|
}
|
|
|
|
AZ::Outcome<AZStd::vector<AZ::Data::ProductDependency>, AZStd::string> GetAllProductDependencies(const AZ::Data::AssetId& id) override
|
|
{
|
|
AZStd::vector<AZ::Data::ProductDependency> dependencyList;
|
|
bool foundAsset{ false };
|
|
for (const AZ::Data::AssetId& assetId : m_assetIds)
|
|
{
|
|
if (assetId == id)
|
|
{
|
|
foundAsset = true;
|
|
}
|
|
else if (foundAsset)
|
|
{
|
|
AZ::Data::ProductDependency thisDependency;
|
|
thisDependency.m_assetId = assetId;
|
|
dependencyList.emplace_back(AZ::Data::ProductDependency(assetId, {}));
|
|
}
|
|
}
|
|
if (dependencyList.size())
|
|
{
|
|
return AZ::Success(dependencyList);
|
|
}
|
|
return AZ::Failure(AZStd::string("Asset not found"));
|
|
}
|
|
|
|
bool TestAddSeedsFor(const AzFramework::AssetSeedList& seedList, AZ::u32 sourceId)
|
|
{
|
|
return AddSeedsFor(seedList, sourceId);
|
|
}
|
|
|
|
bool TestRemoveSeedsFor(const AzFramework::AssetSeedList& seedList, AZ::u32 sourceId)
|
|
{
|
|
return RemoveSeedsFor(seedList, sourceId);
|
|
}
|
|
|
|
bool TestAddSeedList(const char* seedListName)
|
|
{
|
|
return AddSeedList(seedListName);
|
|
}
|
|
|
|
bool TestRemoveSeedList(const char* seedListName)
|
|
{
|
|
return RemoveSeedList(seedListName);
|
|
}
|
|
|
|
AZ::Outcome<AzFramework::AssetSeedList, AZStd::string> LoadSeedList(const char* fileName, AZStd::string& seedFilepath) override
|
|
{
|
|
if (m_validSeedPath == fileName)
|
|
{
|
|
seedFilepath = fileName;
|
|
return AZ::Success(m_validSeedList);
|
|
}
|
|
return AZ::Failure(AZStd::string("Invalid List"));
|
|
}
|
|
|
|
AzFramework::AssetSeedList m_validSeedList;
|
|
AZStd::string m_validSeedPath;
|
|
AZ::Data::AssetId m_assetIds[NumTestAssets];
|
|
};
|
|
|
|
struct AssetValidationTest
|
|
: UnitTest::ScopedAllocatorSetupFixture,
|
|
UnitTest::SetRestoreFileIOBaseRAII,
|
|
AzFramework::ApplicationRequests::Bus::Handler
|
|
{
|
|
AssetValidationTest() : UnitTest::SetRestoreFileIOBaseRAII(m_fileIO)
|
|
{
|
|
if (!AZ::SettingsRegistry::Get())
|
|
{
|
|
AZ::SettingsRegistry::Register(&m_registry);
|
|
|
|
auto projectPathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey)
|
|
+ "/project_path";
|
|
m_registry.Set(projectPathKey, (AZ::IO::FixedMaxPath(GetEngineRoot()) / "AutomatedTesting").Native());
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry);
|
|
|
|
// Set the engine root to the temporary directory and re-update the runtime file paths
|
|
auto enginePathKey = AZ::SettingsRegistryInterface::FixedValueString(AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey)
|
|
+ "/engine_path";
|
|
m_registry.Set(enginePathKey, GetEngineRoot());
|
|
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(m_registry);
|
|
}
|
|
}
|
|
|
|
void NormalizePath(AZStd::string&) override
|
|
{
|
|
AZ_Assert(false, "Not implemented");
|
|
}
|
|
|
|
void NormalizePathKeepCase(AZStd::string&) override
|
|
{
|
|
AZ_Assert(false, "Not implemented");
|
|
}
|
|
|
|
void CalculateBranchTokenForEngineRoot([[maybe_unused]] AZStd::string& token) const override
|
|
{
|
|
AZ_Assert(false, "Not implemented");
|
|
}
|
|
|
|
const char* GetEngineRoot() const override
|
|
{
|
|
return m_tempDir.GetDirectory();
|
|
}
|
|
|
|
void SetUp() override
|
|
{
|
|
using namespace ::testing;
|
|
|
|
ASSERT_TRUE(m_tempDir.IsValid());
|
|
|
|
AzFramework::ApplicationRequests::Bus::Handler::BusConnect();
|
|
}
|
|
|
|
void TearDown() override
|
|
{
|
|
AzFramework::ApplicationRequests::Bus::Handler::BusDisconnect();
|
|
}
|
|
|
|
bool CreateDummyFile(const char* path, const char* seedFileName, AZStd::string_view contents, AZStd::string& subfolderPath) const;
|
|
|
|
AZ::IO::LocalFileIO m_fileIO;
|
|
UnitTest::ScopedTemporaryDirectory m_tempDir;
|
|
AZ::SettingsRegistryImpl m_registry;
|
|
};
|