1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117 |
- /*
- * 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
- *
- */
- #include <AzTest/AzTest.h>
- #include <AzTest/Utils.h>
- #include <AzCore/PlatformId/PlatformId.h>
- #include <AzCore/UnitTest/UnitTest.h>
- #include <AzCore/IO/Path/Path.h>
- #include <AzFramework/IO/LocalFileIO.h>
- #include <AzFramework/Asset/XmlSchemaAsset.h>
- #include <AzFramework/StringFunc/StringFunc.h>
- #include <AzCore/Serialization/SerializeContext.h>
- #include <AzCore/Component/ComponentApplication.h>
- #include <AzCore/UnitTest/TestTypes.h>
- #include <AzCore/UnitTest/UnitTest.h>
- #include <AzCore/Utils/Utils.h>
- #include <Builders/CopyDependencyBuilder/CfgBuilderWorker/CfgBuilderWorker.h>
- #include <Builders/CopyDependencyBuilder/FontBuilderWorker/FontBuilderWorker.h>
- #include <Builders/CopyDependencyBuilder/SchemaBuilderWorker/SchemaBuilderWorker.h>
- #include <Builders/CopyDependencyBuilder/XmlBuilderWorker/XmlBuilderWorker.h>
- #include <Builders/CopyDependencyBuilder/EmfxWorkspaceBuilderWorker/EmfxWorkspaceBuilderWorker.h>
- namespace UnitTest
- {
- using namespace CopyDependencyBuilder;
- using namespace AZ;
- using namespace AssetBuilderSDK;
- class CopyDependencyBuilderTest
- : public UnitTest::LeakDetectionFixture
- , public UnitTest::TraceBusRedirector
- , private AzToolsFramework::AssetSystemRequestBus::Handler
- {
- protected:
- void SetUp() override
- {
- m_app.reset(aznew AZ::ComponentApplication());
- AZ::ComponentApplication::Descriptor desc;
- desc.m_useExistingAllocator = true;
- AZ::ComponentApplication::StartupParameters startupParameters;
- startupParameters.m_loadSettingsRegistry = false;
- m_app->Create(desc, startupParameters);
- if constexpr (AZ::g_currentPlatform == AZ::PlatformID::PLATFORM_WINDOWS_64)
- {
- m_currentPlatform = "pc";
- }
- else
- {
- m_currentPlatform = AZ::GetPlatformName(AZ::g_currentPlatform);
- AZStd::to_lower(m_currentPlatform.begin(), m_currentPlatform.end());
- }
- // Startup default local FileIO (hits OSAllocator) if not already setup.
- auto fileIo = AZ::IO::FileIOBase::GetInstance();
- if (fileIo == nullptr)
- {
- fileIo = aznew AZ::IO::LocalFileIO();
- AZ::IO::FileIOBase::SetInstance(fileIo);
- }
- const AZStd::string engineRoot = AZ::Test::GetEngineRootPath();
- AZ::IO::FileIOBase::GetInstance()->SetAlias("@engroot@", engineRoot.c_str());
- AZ::IO::Path assetRoot(AZ::Utils::GetProjectPath());
- assetRoot /= "Cache";
- AZ::IO::FileIOBase::GetInstance()->SetAlias("@products@", assetRoot.c_str());
- // Set the @gemroot:<gem-name> alias for active gems
- if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
- {
- AZ::Test::AddActiveGem("LmbrCentral", *settingsRegistry, fileIo);
- }
- SerializeContext* serializeContext;
- ComponentApplicationBus::BroadcastResult(serializeContext, &ComponentApplicationRequests::GetSerializeContext);
- ASSERT_TRUE(serializeContext);
- AzFramework::VersionSearchRule::Reflect(serializeContext);
- AzFramework::XmlSchemaAttribute::Reflect(serializeContext);
- AzFramework::XmlSchemaElement::Reflect(serializeContext);
- AzFramework::MatchingRule::Reflect(serializeContext);
- AzFramework::SearchRuleDefinition::Reflect(serializeContext);
- AzFramework::DependencySearchRule::Reflect(serializeContext);
- AzFramework::XmlSchemaAsset::Reflect(serializeContext);
- AZ::Debug::TraceMessageBus::Handler::BusConnect();
- AzToolsFramework::AssetSystemRequestBus::Handler::BusConnect();
- }
- void TearDown() override
- {
- AzToolsFramework::AssetSystemRequestBus::Handler::BusDisconnect();
- AZ::Debug::TraceMessageBus::Handler::BusDisconnect();
- delete AZ::IO::FileIOBase::GetInstance();
- AZ::IO::FileIOBase::SetInstance(nullptr);
- m_app->Destroy();
- m_app = nullptr;
- }
- static constexpr char testFileFolder[] = "@gemroot:LmbrCentral@/Code/Tests/";
- AZStd::string GetFullPath(AZStd::string_view fileName)
- {
- return AZStd::string::format("%s%.*s", testFileFolder, aznumeric_cast<int>(fileName.size()), fileName.data());
- }
- void TestFailureCase(CopyDependencyBuilderWorker* worker, AZStd::string_view fileName, bool expectedResult = false)
- {
- AssetBuilderSDK::ProductPathDependencySet resolvedPaths;
- AZStd::vector<AssetBuilderSDK::ProductDependency> productDependencies;
- AssetBuilderSDK::ProcessJobRequest request;
- request.m_fullPath = GetFullPath(fileName);
- request.m_sourceFile = fileName;
- request.m_platformInfo.m_identifier = m_currentPlatform;
- bool result = worker->ParseProductDependencies(request, productDependencies, resolvedPaths);
- ASSERT_EQ(result, expectedResult);
- ASSERT_EQ(resolvedPaths.size(), 0);
- ASSERT_EQ(productDependencies.size(), 0);
- }
- void TestSuccessCase(
- CopyDependencyBuilderWorker* worker,
- AZStd::string_view fileName,
- const AZStd::vector<const char*>& expectedPathDependencies)
- {
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(worker, fileName, expectedPathDependencies, expectedProductDependencies);
- }
- void TestSuccessCase(
- CopyDependencyBuilderWorker* worker,
- AZStd::string_view fileName,
- const AZStd::vector<const char*>& expectedPathDependencies,
- const AZStd::vector<AssetBuilderSDK::ProductDependency>& expectedProductDependencies,
- const AZStd::string watchFolder = {})
- {
- AssetBuilderSDK::ProductPathDependencySet resolvedPaths;
- AZStd::vector<AssetBuilderSDK::ProductDependency> productDependencies;
- size_t referencedFilePathsCount = expectedPathDependencies.size();
- size_t referencedProductDependenciesCount = expectedProductDependencies.size();
- AssetBuilderSDK::ProductPathDependencySet expectedResolvedPaths;
- for (const char* path : expectedPathDependencies)
- {
- expectedResolvedPaths.emplace(path, AssetBuilderSDK::ProductPathDependencyType::ProductFile);
- }
- AssetBuilderSDK::ProcessJobRequest request;
- request.m_fullPath = GetFullPath(fileName);
- request.m_sourceFile = fileName;
- request.m_platformInfo.m_identifier = m_currentPlatform;
- request.m_watchFolder = watchFolder;
- bool result = worker->ParseProductDependencies(request, productDependencies, resolvedPaths);
- ASSERT_TRUE(result);
- ASSERT_EQ(resolvedPaths.size(), referencedFilePathsCount);
- ASSERT_EQ(productDependencies.size(), referencedProductDependenciesCount);
- if (referencedFilePathsCount > 0)
- {
- for (const AssetBuilderSDK::ProductPathDependency& dependency : expectedResolvedPaths)
- {
- ASSERT_TRUE(resolvedPaths.find(dependency) != resolvedPaths.end()) << "Expected path dependency is not found in the process result";
- }
- }
- if (referencedProductDependenciesCount > 0)
- {
- for (const AssetBuilderSDK::ProductDependency& dependency : productDependencies)
- {
- bool expectedDependencyExists = false;
- for (const AssetBuilderSDK::ProductDependency& expectedProductDependency : expectedProductDependencies)
- {
- if (expectedProductDependency.m_dependencyId == dependency.m_dependencyId
- && expectedProductDependency.m_flags == dependency.m_flags)
- {
- expectedDependencyExists = true;
- break;
- }
- }
- ASSERT_TRUE(expectedDependencyExists) << "Expected product dependency is not found in the process result";
- }
- }
- }
- void TestSuccessCase(CopyDependencyBuilderWorker* worker, AZStd::string_view fileName, const char* expectedFile)
- {
- AZStd::vector<const char*> expectedFiles;
- expectedFiles.push_back(expectedFile);
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(worker, fileName, expectedFiles, expectedProductDependencies);
- }
- void TestSuccessCaseNoDependencies(CopyDependencyBuilderWorker* worker, AZStd::string_view fileName)
- {
- AZStd::vector<const char*> expectedFiles;
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(worker, fileName, expectedFiles, expectedProductDependencies);
- }
- //////////////////////////////////////////////////////////////////////////
- // AzToolsFramework::AssetSystem::AssetSystemRequestBus::Handler overrides
- bool GetRelativeProductPathFromFullSourceOrProductPath([[maybe_unused]] const AZStd::string& fullPath, [[maybe_unused]] AZStd::string& relativeProductPath) override { return true; }
- bool GenerateRelativeSourcePath(
- [[maybe_unused]] const AZStd::string& sourcePath, [[maybe_unused]] AZStd::string& relativePath,
- [[maybe_unused]] AZStd::string& watchFolder) override { return true; }
- bool GetFullSourcePathFromRelativeProductPath([[maybe_unused]] const AZStd::string& relPath, [[maybe_unused]] AZStd::string& fullSourcePath) override { return true; }
- bool GetAssetInfoById([[maybe_unused]] const AZ::Data::AssetId& assetId, [[maybe_unused]] const AZ::Data::AssetType& assetType, [[maybe_unused]] const AZStd::string& platformName, [[maybe_unused]] AZ::Data::AssetInfo& assetInfo, [[maybe_unused]] AZStd::string& rootFilePath) override { return true; }
- bool GetSourceInfoBySourcePath([[maybe_unused]] const char* sourcePath, [[maybe_unused]] AZ::Data::AssetInfo& assetInfo, [[maybe_unused]] AZStd::string& watchFolder) override { return true; }
- bool GetSourceInfoBySourceUUID([[maybe_unused]] const AZ::Uuid& sourceUuid, [[maybe_unused]] AZ::Data::AssetInfo& assetInfo, [[maybe_unused]] AZStd::string& watchFolder) override { return true; }
- bool GetScanFolders([[maybe_unused]] AZStd::vector<AZStd::string>& scanFolders) override { return true; }
- bool IsAssetPlatformEnabled([[maybe_unused]] const char* platform) override { return true; }
- int GetPendingAssetsForPlatform([[maybe_unused]] const char* platform) override { return 0; }
- bool GetAssetsProducedBySourceUUID([[maybe_unused]] const AZ::Uuid& sourceUuid, [[maybe_unused]] AZStd::vector<AZ::Data::AssetInfo>& productsAssetInfo) override { return true; }
- bool GetAssetSafeFolders(AZStd::vector<AZStd::string>& assetSafeFolders) override
- {
- char resolvedBuffer[AZ_MAX_PATH_LEN] = { 0 };
- AZ::IO::FileIOBase::GetInstance()->ResolvePath(GetFullPath("Xmls").c_str(), resolvedBuffer, AZ_MAX_PATH_LEN);
- assetSafeFolders.emplace_back(resolvedBuffer);
- return true;
- }
- bool ClearFingerprintForAsset([[maybe_unused]] const AZStd::string& sourcePath) override { return false; }
- // When supressing AZ_Errors to count how many occur,
- // you need to tell it you expect double the number of errors.
- const int SuppressedErrorMultiplier = 2;
- AZStd::unique_ptr<AZ::ComponentApplication> m_app;
- AZStd::string m_currentPlatform;
- };
- TEST_F(CopyDependencyBuilderTest, TestCfgBuilderWorker_EmptyCfg_NoDependenciesNoErrors)
- {
- ProductPathDependencySet resolvedPaths;
- bool result = CfgBuilderWorker::ParseProductDependenciesFromCfgContents(
- "arbitraryFileName",
- "",
- resolvedPaths);
- ASSERT_TRUE(result);
- ASSERT_EQ(resolvedPaths.size(), 0);
- }
- struct CfgTestHelper
- {
- AZStd::string m_command;
- ProductPathDependency m_expectedDependency;
- };
- AZStd::string ConstructCfgFromHelpers(const AZStd::vector<CfgTestHelper>& helpers)
- {
- AZStd::string result;
- for (const CfgTestHelper& helper : helpers)
- {
- result += AZStd::string::format("%s=%s\n", helper.m_command.c_str(), helper.m_expectedDependency.m_dependencyPath.c_str());
- }
- return result;
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlBuilderWorker_VegetationDescriptorProduct_AssetTypeValid)
- {
- const char vegDescriptorTestName[] = "somefile.vegdescriptorlist";
- AZ::Data::AssetType vegDescriptorListType("{60961B36-E3CA-4877-B197-1462C1363F6E}"); // DescriptorListAsset in Vegetation Gem
- XmlBuilderWorker testBuilder;
- AZ::Data::AssetType parsedAssetType = testBuilder.GetAssetType(vegDescriptorTestName);
- ASSERT_EQ(parsedAssetType, vegDescriptorListType);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlBuilderWorker_InvalidExtensionProduct_AssetTypeNull)
- {
- const char nullTestType[] = "somefile.vegdescriptorlist2";
- AZ::Data::AssetType nullType = AZ::Data::AssetType::CreateNull();
- XmlBuilderWorker testBuilder;
- AZ::Data::AssetType parsedAssetType = testBuilder.GetAssetType(nullTestType);
- ASSERT_EQ(parsedAssetType, nullType);
- }
- TEST_F(CopyDependencyBuilderTest, TestCfgBuilderWorker_ValidCommands_CorrectDependencies)
- {
- // Testing every row of the supported config files and supported extensions won't accomplish
- // much besides forcing someone to keep two lists in sync. If these test cases work (source extension, product extensions), then the system works.
- AZStd::vector<CfgTestHelper> commands =
- {
- { "game_load_screen_uicanvas_path", { "somefile.uicanvas", ProductPathDependencyType::ProductFile }},
- { "sys_splashscreen", { "arbitraryFile.bmp", ProductPathDependencyType::SourceFile } },
- };
- ProductPathDependencySet resolvedPaths;
- bool result = CfgBuilderWorker::ParseProductDependenciesFromCfgContents(
- "arbitraryFileName",
- ConstructCfgFromHelpers(commands),
- resolvedPaths);
- ASSERT_TRUE(result);
- ASSERT_EQ(resolvedPaths.size(), commands.size());
- for (CfgTestHelper& helper : commands)
- {
- // Paths are stored in lowercase in the database
- AZStd::to_lower(helper.m_expectedDependency.m_dependencyPath.begin(), helper.m_expectedDependency.m_dependencyPath.end());
- ProductPathDependencySet::iterator foundFile = resolvedPaths.find(helper.m_expectedDependency);
- ASSERT_NE(foundFile, resolvedPaths.end());
- }
- }
- TEST_F(CopyDependencyBuilderTest, TestCfgBuilderWorker_CommentedCommand_NoDependenciesNoError)
- {
- const AZStd::vector<CfgTestHelper> commands =
- {
- // Test product file types
- { "--game_load_screen_uicanvas_path", { "somefile.uicanvas", ProductPathDependencyType::ProductFile }},
- { "--sys_splashscreen", { "arbitraryFile.bmp", ProductPathDependencyType::SourceFile } },
- };
- ProductPathDependencySet resolvedPaths;
- bool result = CfgBuilderWorker::ParseProductDependenciesFromCfgContents(
- "arbitraryFileName",
- ConstructCfgFromHelpers(commands),
- resolvedPaths);
- ASSERT_TRUE(result);
- // Both commands were commented out, so there should be no resolved paths.
- ASSERT_EQ(resolvedPaths.size(), 0);
- }
- TEST_F(CopyDependencyBuilderTest, TestCfgBuilderWorker_ValidCommandInvalidValue_NoDependenciesError)
- {
- const AZStd::vector<CfgTestHelper> commands =
- {
- { "game_load_screen_uicanvas_path", { "Invalid string with illegal characters!", ProductPathDependencyType::ProductFile }}
- };
- ProductPathDependencySet resolvedPaths;
- AZ_TEST_START_ASSERTTEST;
- bool result = CfgBuilderWorker::ParseProductDependenciesFromCfgContents(
- "arbitraryFileName",
- ConstructCfgFromHelpers(commands),
- resolvedPaths);
- // Expected: 1 error, on the illegal characters in the command's value.
- AZ_TEST_STOP_ASSERTTEST(1 * SuppressedErrorMultiplier);
- ASSERT_FALSE(result);
- ASSERT_EQ(resolvedPaths.size(), 0);
- }
- TEST_F(CopyDependencyBuilderTest, TestCfgBuilderWorker_ValidCommandEmptyValue_NoDependenciesError)
- {
- const AZStd::vector<CfgTestHelper> commands =
- {
- { "game_load_screen_uicanvas_path", { "", ProductPathDependencyType::ProductFile }}
- };
- ProductPathDependencySet resolvedPaths;
- AZ_TEST_START_ASSERTTEST;
- bool result = CfgBuilderWorker::ParseProductDependenciesFromCfgContents(
- "arbitraryFileName",
- ConstructCfgFromHelpers(commands),
- resolvedPaths);
- // Expected: 1 error, on the empty value.
- AZ_TEST_STOP_ASSERTTEST(1 * SuppressedErrorMultiplier);
- ASSERT_FALSE(result);
- ASSERT_EQ(resolvedPaths.size(), 0);
- }
- TEST_F(CopyDependencyBuilderTest, TestCfgBuilderWorker_UnhandledCommandValidData_NoDependenciesNoError)
- {
- const AZStd::vector<CfgTestHelper> commands =
- {
- { "command_that_does_not_exist", { "thislookslikea.file", ProductPathDependencyType::ProductFile }}
- };
- ProductPathDependencySet resolvedPaths;
- bool result = CfgBuilderWorker::ParseProductDependenciesFromCfgContents(
- "arbitraryFileName",
- ConstructCfgFromHelpers(commands),
- resolvedPaths);
- ASSERT_TRUE(result);
- ASSERT_EQ(resolvedPaths.size(), 0);
- }
- TEST_F(CopyDependencyBuilderTest, TestCfgBuilderWorker_ValidCommandsInvalidExtension_ErrorNoDependencies)
- {
- // Testing every row of the supported config files and supported extensions won't accomplish
- // much besides forcing someone to keep two lists in sync. If these test cases work (source extension, product extensions), then the system works.
- AZStd::vector<CfgTestHelper> commands =
- {
- { "game_load_screen_uicanvas_path", { "somefile.badextension", ProductPathDependencyType::ProductFile }}
- };
- ProductPathDependencySet resolvedPaths;
- AZ_TEST_START_ASSERTTEST;
- bool result = CfgBuilderWorker::ParseProductDependenciesFromCfgContents(
- "arbitraryFileName",
- ConstructCfgFromHelpers(commands),
- resolvedPaths);
- // Expected: 1 error, on the invalid extension.
- AZ_TEST_STOP_ASSERTTEST(1 * SuppressedErrorMultiplier);
- ASSERT_FALSE(result);
- ASSERT_EQ(resolvedPaths.size(), 0);
- }
- TEST_F(CopyDependencyBuilderTest, TestFontfamilyAsset_MultipleDependencies_OutputProductDependencies)
- {
- // Tests processing a FontFamilyExample.fontfamily file containing multiple dependencies
- // Should output 4 dependencies
- AZStd::vector<const char*> expectedPaths = {
- "Fonts/fontexample-regular.font",
- "Fonts/fontexample-bold.font",
- "Fonts/fontexample-italic.font",
- "Fonts/fontexample-bolditalic.font"
- };
- AZStd::string fileName = "Fonts/FontFamilyExample.fontfamily";
- FontBuilderWorker builderWorker;
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestFontAsset_SingleDependency_OutputProductDependency)
- {
- // Tests processing a FontExample.font file containing 1 dependency
- // Should output 1 dependency
- AZStd::string fileName = "Fonts/FontExample.font";
- FontBuilderWorker builderWorker;
- TestSuccessCase(&builderWorker, fileName, "Fonts/FontExample.ttf");
- }
- TEST_F(CopyDependencyBuilderTest, TestFontAsset_NoDependency_OutputNoProductDependencies)
- {
- // Tests processing a FontExampleNoDependency.font file containing 0 dependency
- // Should output 0 dependencies and return true
- AZStd::string fileName = "Fonts/FontExampleNoDependency.font";
- FontBuilderWorker builderWorker;
- TestSuccessCaseNoDependencies(&builderWorker, fileName);
- }
- TEST_F(CopyDependencyBuilderTest, TestFontAsset_InvalidFilePath_OutputNoProductDependencies)
- {
- // Tests passing an invalid file path in
- // Should output 0 dependency and return false
- AZStd::string fileName = "Fonts/InvalidPathExample.font";
- FontBuilderWorker builderWorker;
- TestFailureCase(&builderWorker, fileName);
- }
- TEST_F(CopyDependencyBuilderTest, TestFontAsset_EmptyFile_OutputNoProductDependencies)
- {
- // Tests passing an empty file in
- // Should output 0 dependency and return false
- AZStd::string fileName = "Fonts/EmptyFontExample.font";
- FontBuilderWorker builderWorker;
- TestFailureCase(&builderWorker, fileName);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_ExcludedSourceFilePath_NoProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths;
- AZStd::string fileName = "Xmls/ExcludedFilePathExample.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithVersionConstraints"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_InvalidSchemaFormat_NoProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths;
- AZStd::string fileName = "Xmls/XmlExample.xml";
- XmlBuilderWorker builderWorker;
- AZStd::string fullPath = GetFullPath("Xmls/Schema/Invalid/InvalidFormat");
- builderWorker.AddSchemaFileDirectory(fullPath);
- AZ_TEST_START_TRACE_SUPPRESSION;
- // The expected result is true because the invalid schema doesn't mean this XML file itself has failed to parse, it may be matched
- // by other schemas.
- TestFailureCase(&builderWorker, fileName, /*expectedResult*/ true);
- // Three errors occur: RapidXML parse error (unexpected end of data), ObjectStream XML parse error and schema file loading error
- AZ_TEST_STOP_TRACE_SUPPRESSION(3 * SuppressedErrorMultiplier);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_InvalidSourceFilePath_NoProductDependencies)
- {
- AZStd::string fileName = "Xmls/InvalidFilePathExample.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/FullFeatured"));
- AZStd::vector<const char*> expectedPaths;
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- AZ_TEST_START_TRACE_SUPPRESSION;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- // One error occurs: Cannot open the source file
- AZ_TEST_STOP_TRACE_SUPPRESSION(1 * SuppressedErrorMultiplier);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_InvalidSourceFileVersionNumberFormat_NoProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths;
- AZStd::string fileName = "Xmls/XmlExampleInvalidVersionNumberFormat.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithVersionConstraints"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_NoMatchedSchema_NoProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths;
- AZStd::string fileName = "Xmls/NoMatchedSchemaExample.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/FullFeatured"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_SchemaMissingRules_NoProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths;
- AZStd::string fileName = "Xmls/XmlExample.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/Invalid/MissingRules"));
- AZ_TEST_START_TRACE_SUPPRESSION;
- TestFailureCase(&builderWorker, fileName, true);
- // One error occurs: Matching rules are missing
- AZ_TEST_STOP_TRACE_SUPPRESSION(1 * SuppressedErrorMultiplier);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_SchemaEmptyAttributeValue_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "dependency2.txt",
- "dependency3.txt",
- "dependency4.txt",
- "dependency5.txt",
- "dependency6.txt",
- "dependency7.txt"
- };
- AZStd::string fileName = "Xmls/XmlExampleEmptyAttributeValue.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/FullFeatured"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_DependencySearchRuleForSpecificAttribute_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "dependency1.txt",
- "dependency2.txt",
- "dependency6.txt",
- "dependency7.txt"
- };
- AZStd::string fileName = "Xmls/XmlExampleWithoutVersion.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/SpecificAttribute"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_DependencySearchRuleForSpecificElement_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "dependency3.txt",
- "dependency4.txt",
- "dependency5.txt"
- };
- AZStd::string fileName = "Xmls/XmlExampleWithoutVersion.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/SpecificElement"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_DependencySearchRuleRelativeToXmlRootNode_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "dependency1.txt",
- "dependency2.txt"
- };
- AZStd::string fileName = "Xmls/XmlExampleWithoutVersion.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/RelativeToXmlRootNode"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_DependencySearchRuleWithExpectedExtension_OutputProductDependencies)
- {
- AZStd::string fileName = "Xmls/XmlExampleWithoutExtension.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/ExpectedExtension"));
- TestSuccessCase(&builderWorker, fileName, "dependency2.txt");
- }
- // The schema supports different extensions at the same location in the file.
- // This matches the behavior of systems like materials referencing textures: They can reference the source (png/tif) or product (dds)
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_MultipleOverlappingOptionalExtensions_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "Extension1.ext1",
- "Extension2.ext2"
- };
- AZStd::string fileName = "Xmls/XmlExampleMultipleMatchingExtensions.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/MultipleExtensionsSamePath"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_DependencySearchRuleWithOptionalAttribute_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "dependency1.txt",
- "dependency2.txt"
- };
- AZStd::string fileName = "Xmls/XmlExampleWithoutVersion.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/OptionalAttribute"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_DependencySearchRuleWithMissingRequiredAttribute_NoProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths;
- AZStd::string fileName = "Xmls/XmlExampleWithoutVersion.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/RequiredAttribute"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_DependencySearchRuleWithOptionalElement_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "dependency1.txt",
- "dependency2.txt"
- };
- AZStd::string fileName = "Xmls/XmlExampleWithoutVersion.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/OptionalElement"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_DependencySearchRuleWithMissingRequiredElement_NoProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths;
- AZStd::string fileName = "Xmls/XmlExampleWithoutVersion.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/RequiredElements"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_SourceFileWithoutVersionSchemaWithVersionConstraints_NoProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths;
- AZStd::string fileName = "Xmls/XmlExampleWithoutVersion.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithVersionConstraints"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_SourceFileWithVersionOutOfRangeSchemaWithVersionConstraints_NoProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths;
- AZStd::string fileName = "Xmls/XmlExampleVersionOutOfRange.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithVersionConstraints"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_SourceFileWithVersionSchemaWithVersionConstraints_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "dependency1.txt",
- "dependency2.txt",
- "dependency3.txt",
- "dependency4.txt",
- "dependency5.txt",
- "dependency6.txt",
- "dependency7.txt"
- };
- AZStd::string fileName = "Xmls/XmlExample.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithVersionConstraints"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_SourceFileWithOneVersionPartSchemaWithVersionConstraints_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "dependency1.txt",
- "dependency2.txt",
- "dependency3.txt",
- "dependency4.txt",
- "dependency5.txt",
- "dependency6.txt",
- "dependency7.txt"
- };
- AZStd::string fileName = "Xmls/XmlExampleWithOneVersionPart.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithVersionConstraints"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_SourceFileWithTwoVersionPartsSchemaWithVersionConstraints_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "dependency1.txt",
- "dependency2.txt",
- "dependency3.txt",
- "dependency4.txt",
- "dependency5.txt",
- "dependency6.txt",
- "dependency7.txt"
- };
- AZStd::string fileName = "Xmls/XmlExampleWithTwoVersionParts.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithVersionConstraints"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_SourceFileWithThreeVersionPartsSchemaWithVersionConstraints_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "dependency1.txt",
- "dependency2.txt",
- "dependency3.txt",
- "dependency4.txt",
- "dependency5.txt",
- "dependency6.txt",
- "dependency7.txt"
- };
- AZStd::string fileName = "Xmls/XmlExampleWithThreeVersionParts.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithVersionConstraints"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_SourceFileWithInvalidVersionPartsCountSchemaWithVersionConstraints_OutputNoProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths;
- AZStd::string fileName = "Xmls/XmlExampleWithInvalidVersionPartsCount.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithVersionConstraints"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_SourceFileWithInvalidVersionPartsSeparatorSchemaWithVersionConstraints_OutputNoProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths;
- AZStd::string fileName = "Xmls/XmlExampleWithInvalidVersionPartsSeparator.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithVersionConstraints"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_SourceFileWithVersionSchemaWithoutVersionConstraints_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "dependency1.txt",
- "dependency2.txt",
- "dependency3.txt",
- "dependency4.txt",
- "dependency5.txt",
- "dependency6.txt",
- "dependency7.txt"
- };
- AZStd::string fileName = "Xmls/XmlExample.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/FullFeatured"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_SourceFileWithoutVersionSchemaWithoutVersionConstraints_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "dependency1.txt",
- "dependency2.txt",
- "dependency3.txt",
- "dependency4.txt",
- "dependency5.txt",
- "dependency6.txt",
- "dependency7.txt"
- };
- AZStd::string fileName = "Xmls/XmlExampleWithoutVersion.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/FullFeatured"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_CreateJobsWithValidSourceFile_OutputSourceDependencies)
- {
- AssetBuilderSDK::CreateJobsRequest request;
- AssetBuilderSDK::CreateJobsResponse response;
- request.m_sourceFile = "Tests/Xmls/XmlExampleWithoutVersion.xml";
- request.m_watchFolder = "@gemroot:LmbrCentral@/Code/";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/FullFeatured"));
- builderWorker.CreateJobs(request, response);
- ASSERT_TRUE(response.m_sourceFileDependencyList.size() == 1);
- AZStd::vector<AZStd::string> splitedPathList;
- AzFramework::StringFunc::Tokenize(response.m_sourceFileDependencyList[0].m_sourceFileDependencyPath.c_str(), splitedPathList, AZStd::string::format("%c%c",AZ_CORRECT_FILESYSTEM_SEPARATOR, AZ_WRONG_FILESYSTEM_SEPARATOR).c_str());
- ASSERT_EQ(splitedPathList.back(), "Schema.xmlschema");
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_ProductPathRelativeToSourceAssetFolder_OutputProductDependencies)
- {
- AZStd::string product = GetFullPath("Xmls/dependency1.txt");
- AZStd::vector<const char*> expectedPaths = {
- product.c_str()
- };
- AZStd::string fileName = "Xmls/XmlExample.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/PathRelativeToSourceAssetFolder"));
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_ProductPathRelativeToProductAssetFolder_OutputProductDependencies)
- {
- AZStd::string product = "Xmls/dependency1.txt";
- AZStd::vector<const char*> expectedPaths = {
- product.c_str()
- };
- AZStd::string fileName = "Xmls/XmlExample.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/PathRelativeToProductAssetFolder"));
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies, testFileFolder);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_ProductDependencyWithAssetId_OutputProductDependencies)
- {
- AZStd::string product = GetFullPath("Xmls/dependency1.txt");
- AZStd::vector<const char*> expectedPaths;
- AZ::Data::AssetId expectedAssetId;
- expectedAssetId.m_guid = AZ::Uuid("00000000-0000-0000-0000-000000000000");
- expectedAssetId.m_subId = 0;
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- expectedProductDependencies.emplace_back(AssetBuilderSDK::ProductDependency(expectedAssetId, {}));
- AZStd::string fileName = "Xmls/XmlExampleWithAssetId.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/ProductDependencyWithAssetId"));
- TestSuccessCase(&builderWorker, fileName, expectedPaths, expectedProductDependencies);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_MatchRegexMatches_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "Extension1.ext1"
- };
- AZStd::string fileName = "Xmls/XmlExampleMultipleMatchingExtensions.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/MatchPattern"));
- TestSuccessCase(&builderWorker, fileName, expectedPaths);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_MatchRegexNoMatches_NoProductDependencies)
- {
- AZStd::string fileName = "Xmls/XmlExample.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/MatchPattern"));
- TestSuccessCaseNoDependencies(&builderWorker, fileName);
- }
- TEST_F(CopyDependencyBuilderTest, TestXmlAsset_FindAndReplace_OutputProductDependencies)
- {
- AZStd::vector<const char*> expectedPaths = {
- "hello.ext1",
- "hello.ext2"
- };
- AZStd::string fileName = "Xmls/XmlExampleMultipleMatchingExtensions.xml";
- XmlBuilderWorker builderWorker;
- builderWorker.AddSchemaFileDirectory(GetFullPath("Xmls/Schema/WithoutVersionConstraints/FindAndReplace"));
- TestSuccessCase(&builderWorker, fileName, expectedPaths);
- }
- TEST_F(CopyDependencyBuilderTest, TestSchemaAsset_ValidMatchingRules_OutputReverseSourceDependencies)
- {
- AZStd::vector<AZStd::string> expectedPaths = {
- "NoMatchedSchemaExample.xml",
- "XmlExample.xml",
- "XmlExampleEmptyAttributeValue.xml",
- "XmlExampleInvalidVersionNumberFormat.xml",
- "XmlExampleMultipleMatchingExtensions.xml",
- "XmlExampleVersionOutOfRange.xml",
- "XmlExampleWithoutExtension.xml",
- "XmlExampleWithoutVersion.xml",
- "XmlExampleWithOneVersionPart.xml",
- "XmlExampleWithTwoVersionParts.xml",
- "XmlExampleWithThreeVersionParts.xml",
- "XmlExampleWithInvalidVersionPartsSeparator.xml",
- "XmlExampleWithInvalidVersionPartsCount.xml",
- "XmlExampleWithAssetId.xml",
- };
- AZStd::string fileName = "Xmls/XmlExampleWithoutVersion.xml";
- SchemaBuilderWorker builderWorker;
- AssetBuilderSDK::ProcessJobRequest request;
- AssetBuilderSDK::ProcessJobResponse response;
- request.m_fullPath = GetFullPath("Xmls/Schema/WithoutVersionConstraints/FullFeatured/Schema.xmlschema");
- request.m_sourceFile = "Xmls/Schema/WithoutVersionConstraints/FullFeatured/Schema.xmlschema";
- request.m_platformInfo.m_identifier = m_currentPlatform;
- builderWorker.ProcessJob(request, response);
- ASSERT_TRUE(response.m_sourcesToReprocess.size() == expectedPaths.size());
- for (const AZStd::string& reverseSourceDependency : response.m_sourcesToReprocess)
- {
- AZStd::vector<AZStd::string> splitedPathList;
- AzFramework::StringFunc::Tokenize(reverseSourceDependency.c_str(), splitedPathList, AZStd::string::format("%c%c", AZ_CORRECT_FILESYSTEM_SEPARATOR, AZ_WRONG_FILESYSTEM_SEPARATOR).c_str());
- ASSERT_TRUE(AZStd::find(expectedPaths.begin(), expectedPaths.end(), splitedPathList.back()) != expectedPaths.end());
- }
- }
- TEST_F(CopyDependencyBuilderTest, TestSchemaAsset_InvalidFormat_OutputReverseSourceDependencies)
- {
- AZStd::string fileName = "Xmls/XmlExampleWithoutVersion.xml";
- SchemaBuilderWorker builderWorker;
- AssetBuilderSDK::ProcessJobRequest request;
- AssetBuilderSDK::ProcessJobResponse response;
- request.m_fullPath = GetFullPath("Xmls/Schema/Invalid/InvalidFormat/Schema.xmlschema");
- request.m_sourceFile = "Xmls/Schema/Invalid/InvalidFormat/Schema.xmlschema";
- request.m_platformInfo.m_identifier = m_currentPlatform;
- AZ_TEST_START_TRACE_SUPPRESSION;
- builderWorker.ProcessJob(request, response);
- // Three errors: One from LoadObjectFromFileInPlace, one is from GetReverseSourceDependencies and the other from ProcessJob
- AZ_TEST_STOP_TRACE_SUPPRESSION(3 * SuppressedErrorMultiplier);
- ASSERT_TRUE(response.m_sourcesToReprocess.size() == 0);
- }
- TEST_F(CopyDependencyBuilderTest, TestSchemaAsset_SchemaMissingRules_OutputReverseSourceDependencies)
- {
- AZStd::string fileName = "Xmls/XmlExampleWithoutVersion.xml";
- SchemaBuilderWorker builderWorker;
- AssetBuilderSDK::ProcessJobRequest request;
- AssetBuilderSDK::ProcessJobResponse response;
- request.m_fullPath = GetFullPath("Xmls/Schema/Invalid/MissingRules/Schema.xmlschema");
- request.m_sourceFile = "Xmls/Schema/Invalid/MissingRules/Schema.xmlschema";
- request.m_platformInfo.m_identifier = m_currentPlatform;
- AZ_TEST_START_TRACE_SUPPRESSION;
- builderWorker.ProcessJob(request, response);
- AZ_TEST_STOP_TRACE_SUPPRESSION(SuppressedErrorMultiplier);
- ASSERT_TRUE(response.m_sourcesToReprocess.size() == 0);
- }
- TEST_F(CopyDependencyBuilderTest, TestEmfxWorkSpace_ProductDependencies_Valid)
- {
- AZStd::set<AZStd::string> expectedProductPathDependencies = {
- "foo.actor",
- "foo.motionset",
- "foo.animgraph",
- };
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- AZStd::string fileName = "EmfxWorkSpace/productdependencies.emfxworkspace";
- EmfxWorkspaceBuilderWorker builderWorker;
- AssetBuilderSDK::ProcessJobRequest request;
- AssetBuilderSDK::ProcessJobResponse response;
- request.m_fullPath = GetFullPath("EmfxWorkSpace/productdependencies.emfxworkspace");
- request.m_sourceFile = "EmfxWorkSpace/productdependencies.emfxworkspace";
- request.m_platformInfo.m_identifier = m_currentPlatform;
- builderWorker.ProcessJob(request, response);
- ASSERT_EQ(response.m_outputProducts.size(), 1);
- ASSERT_EQ(response.m_outputProducts[0].m_pathDependencies.size(), 3);
- for (const auto& productDependenciesPath : response.m_outputProducts[0].m_pathDependencies)
- {
- ASSERT_TRUE(expectedProductPathDependencies.find(productDependenciesPath.m_dependencyPath) != expectedProductPathDependencies.end());
- ASSERT_TRUE(productDependenciesPath.m_dependencyType == ProductPathDependencyType::ProductFile);
- }
- }
- TEST_F(CopyDependencyBuilderTest, TestEmfxWorkSpace_NoProductDependencies_Valid)
- {
- AZStd::vector<AssetBuilderSDK::ProductDependency> expectedProductDependencies;
- AZStd::string fileName = "EmfxWorkSpace/noproductdependencies.emfxworkspace";
- EmfxWorkspaceBuilderWorker builderWorker;
- AssetBuilderSDK::ProcessJobRequest request;
- AssetBuilderSDK::ProcessJobResponse response;
- request.m_fullPath = GetFullPath("EmfxWorkSpace/noproductdependencies.emfxworkspace");
- request.m_sourceFile = "EmfxWorkSpace/noproductdependencies.emfxworkspace";
- request.m_platformInfo.m_identifier = m_currentPlatform;
- builderWorker.ProcessJob(request, response);
- ASSERT_EQ(response.m_outputProducts.size(), 1);
- ASSERT_EQ(response.m_outputProducts[0].m_pathDependencies.size(), 0);
- }
- }
|