Initial commit

This commit is contained in:
alexpete
2021-03-05 11:26:34 -08:00
commit a10351f38d
27091 changed files with 5521199 additions and 0 deletions
@@ -0,0 +1,36 @@
<ObjectStream version="3">
<Class name="ProcessJobRequest" version="2" type="{20461454-D2F9-4079-AB95-703905E06002}">
<Class name="AZStd::string" field="Source File" value="Example.fontfamily" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="AZStd::string" field="Watch Folder" value="Output" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="AZStd::string" field="Full Path" value="Output/Example.fontfamily" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="AZ::Uuid" field="Builder Guid" value="{31B74BFD-7046-47AC-A7DA-7D5167E9B2F8}" type="{E152C105-A133-4D03-BBF8-3D4B2FBA3E2A}"/>
<Class name="JobDescriptor" field="Job Description" version="3" type="{BD0472A4-7634-41F3-97EF-00F3B239BAE2}">
<Class name="AZStd::string" field="Additional Fingerprint Info" value="0copy{57767D37-0EBE-43BE-8F60-AB36D2056EF8}" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="int" field="Platform" value="1" type="{72039442-EB38-4D42-A1AD-CB68F7E0EEF6}"/>
<Class name="AZStd::string" field="Platform Identifier" value="pc" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="AZStd::string" field="Job Key" value="fontfamily" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="bool" field="Critical" value="true" type="{A0CA880C-AFE4-43CB-926C-59AC48496112}"/>
<Class name="int" field="Priority" value="1" type="{72039442-EB38-4D42-A1AD-CB68F7E0EEF6}"/>
<Class name="AZStd::unordered_map" field="Job Parameters" type="{4113BC4E-1027-500F-93A2-545C3DBB824D}">
<Class name="AZStd::pair" field="element" type="{3690DA11-3F3B-5A64-B683-471C4BA90FFC}">
<Class name="unsigned int" field="value1" value="1589735409" type="{43DA906B-7DEF-4CA8-9790-854106D3F983}"/>
<Class name="AZStd::string" field="value2" value="fontfamily" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
</Class>
</Class>
<Class name="bool" field="Check Exclusive Lock" value="false" type="{A0CA880C-AFE4-43CB-926C-59AC48496112}"/>
<Class name="bool" field="Fail On Error" value="false" type="{A0CA880C-AFE4-43CB-926C-59AC48496112}"/>
<Class name="AZStd::vector" field="Job Dependency List" type="{DEFBFFD3-D0FA-53B3-B5D3-0ABA49B2FEBD}"/>
</Class>
<Class name="AZStd::string" field="Temp Dir Path" value="Output" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="PlatformInfo" field="Platform Info" version="1" type="{F7DA39A5-C319-4552-954B-3479E2454D3F}">
<Class name="AZStd::string" field="Platform Identifier" value="pc" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="AZStd::unordered_set" field="Tags on Platform" type="{32EC831B-8AE7-5715-998B-C0C723CB61DA}">
<Class name="AZStd::string" field="element" value="tools" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
<Class name="AZStd::string" field="element" value="renderer" type="{03AAAB3F-5C47-5A66-9EBC-D5FA4DB353C9}"/>
</Class>
</Class>
<Class name="AZStd::vector" field="Source File Dependency List" type="{A78563AF-17EE-5D6D-940A-9FE76BD74AB9}"/>
<Class name="AZ::Uuid" field="Source File UUID" value="{A1CEEB96-D5FC-52A6-8678-86722B7DCFB2}" type="{E152C105-A133-4D03-BBF8-3D4B2FBA3E2A}"/>
</Class>
</ObjectStream>
@@ -0,0 +1,112 @@
/*
* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or
* its licensors.
*
* For complete copyright and license terms please see the LICENSE at the root of this
* distribution (the "License"). All use of this software is governed by the License,
* or, if provided, by the license below or the license accompanying this file. Do not
* remove or modify any license notices. This file is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
*
*/
#include "ResourceCompilerLegacy_precompiled.h"
#include "LegacyCompiler.h"
#include <AssetBuilderSDK/AssetBuilderSDK.h>
#include <AzFramework/IO/LocalFileIO.h>
#include <AzCore/Component/ComponentApplication.h>
#include <AzCore/UnitTest/UnitTest.h>
#include <AzCore/UserSettings/UserSettingsComponent.h>
#include <AzToolsFramework/Application/ToolsApplication.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzTest/AzTest.h>
#include <AzTest/Utils.h>
class ResourceCompilerLegacyTest
: public ::testing::Test
, public AZ::RC::LegacyCompiler
{
protected:
void SetUp() override
{
AZ::AllocatorInstance<AZ::SystemAllocator>::Create();
m_app.reset(aznew AzFramework::Application());
AZ::ComponentApplication::Descriptor desc;
desc.m_useExistingAllocator = true;
m_app->Start(desc);
// Without this, the user settings component would attempt to save on finalize/shutdown. Since the file is
// shared across the whole engine, if multiple tests are run in parallel, the saving could cause a crash
// in the unit tests.
AZ::UserSettingsComponentRequestBus::Broadcast(&AZ::UserSettingsComponentRequests::DisableSaveOnFinalize);
AssetBuilderSDK::InitializeSerializationContext();
}
void TearDown() override
{
m_app->Destroy();
m_app.reset();
AZ::AllocatorInstance<AZ::SystemAllocator>::Destroy();
}
AZStd::unique_ptr<AssetBuilderSDK::ProcessJobRequest> WrapReadJobRequest(const char* folder) const
{
return ReadJobRequest(folder);
}
bool WrapWriteResponse(const char* folder, AssetBuilderSDK::ProcessJobResponse& response, bool success = true) const
{
return WriteResponse(folder, response, success);
}
AZStd::unique_ptr<AzFramework::Application> m_app;
};
TEST_F(ResourceCompilerLegacyTest, ReadJobRequest_NoRequestFile_GenerateProcessJobRequest)
{
// Tests without ProcessJobRequest.xml
const char* testFileFolder = "@devroot@/Code/Tools/RC/ResourceCompilerLegacy/Tests";
char testFileResolvedPath[AZ_MAX_PATH_LEN];
AZ::IO::FileIOBase::GetInstance()->ResolvePath(testFileFolder, testFileResolvedPath, AZ_ARRAY_SIZE(testFileResolvedPath));
AZ_TEST_START_TRACE_SUPPRESSION;
ASSERT_FALSE(WrapReadJobRequest(testFileResolvedPath));
// Expected error:
// Unable to load ProcessJobRequest. Not enough information to process this file
AZ_TEST_STOP_TRACE_SUPPRESSION(1);
}
TEST_F(ResourceCompilerLegacyTest, ReadJobRequest_ValidRequestFile_GenerateProcessJobRequest)
{
// Tests reading ProcessJobRequest.xml
const char* testFileFolder = "@devroot@/Code/Tools/RC/ResourceCompilerLegacy/Tests/Output";
char testFileResolvedFolder[AZ_MAX_PATH_LEN];
AZ::IO::FileIOBase::GetInstance()->ResolvePath(testFileFolder, testFileResolvedFolder, AZ_ARRAY_SIZE(testFileResolvedFolder));
ASSERT_TRUE(WrapReadJobRequest(testFileResolvedFolder));
}
TEST_F(ResourceCompilerLegacyTest, WriteJobResponse_ValidProcessJobResponse_WriteProcessJobResponseToDisk)
{
// Tests writing ProcessJobResponse.xml to disk
const char* testFileFolder = "@assets@/Code/Tools/RC/ResourceCompilerLegacy/Tests/Output";
char testFileResolvedFolder[AZ_MAX_PATH_LEN];
AZ::IO::FileIOBase::GetInstance()->ResolvePath(testFileFolder, testFileResolvedFolder, AZ_ARRAY_SIZE(testFileResolvedFolder));
AssetBuilderSDK::ProcessJobResponse response;
ASSERT_TRUE(WrapWriteResponse(testFileResolvedFolder, response));
AZStd::string responseFilePath;
AzFramework::StringFunc::Path::ConstructFull(testFileResolvedFolder, AssetBuilderSDK::s_processJobResponseFileName, responseFilePath);
ASSERT_TRUE(AZ::IO::FileIOBase::GetInstance()->Exists(responseFilePath.c_str()));
ASSERT_TRUE(AZ::IO::FileIOBase::GetInstance()->Remove(responseFilePath.c_str()));
}
AZ_UNIT_TEST_HOOK(DEFAULT_UNIT_TEST_ENV);