Integrating github/staging through commit ab87ed9

This commit is contained in:
alexpete
2021-04-09 11:27:37 -07:00
parent ae62a97894
commit 1044dc3da1
1582 changed files with 29374 additions and 519051 deletions
+51 -35
View File
@@ -12,8 +12,9 @@
#include <AzFramework/API/ApplicationAPI.h>
#include <source/utils/utils.h>
#include <AzCore/Settings/SettingsRegistryImpl.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/UnitTest/TestTypes.h>
#include <AzFramework/StringFunc/StringFunc.h>
#include <Utils/Utils.h>
#include <AzFramework/IO/LocalFileIO.h>
@@ -36,10 +37,27 @@ namespace AssetBundler
AZ::IO::FileIOBase::SetInstance(nullptr);
AZ::IO::FileIOBase::SetInstance(m_localFileIO);
m_tempDir = new UnitTest::ScopedTemporaryDirectory();
auto settingsRegistry = AZ::SettingsRegistry::Get();
if (settingsRegistry == nullptr)
{
m_settingsRegistry = AZStd::make_unique<AZ::SettingsRegistryImpl>();
settingsRegistry = m_settingsRegistry.get();
AZ::SettingsRegistry::Register(settingsRegistry);
}
settingsRegistry->Get(m_oldEngineRoot.Native(), AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder);
settingsRegistry->Set(AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder, m_tempDir->GetDirectory());
}
void TearDown() override
{
// Reset Engine Path if there was an existing Settings Registry from before
auto settingsRegistry = AZ::SettingsRegistry::Get();
settingsRegistry->Set(AZ::SettingsRegistryMergeUtils::FilePathKey_EngineRootFolder, m_oldEngineRoot.Native());
if(settingsRegistry == m_settingsRegistry.get())
{
AZ::SettingsRegistry::Unregister(settingsRegistry);
m_settingsRegistry.reset();
}
delete m_tempDir;
AZ::IO::FileIOBase::SetInstance(nullptr);
delete m_localFileIO;
@@ -53,7 +71,7 @@ namespace AssetBundler
void NormalizePathKeepCase(AZStd::string& /*path*/) override {}
void CalculateBranchTokenForEngineRoot(AZStd::string& /*token*/) const override {}
const char* GetAppRoot() const override
const char* GetEngineRoot() const override
{
return m_tempDir->GetDirectory();
}
@@ -61,56 +79,55 @@ namespace AssetBundler
AZ::IO::FileIOBase* m_priorFileIO = nullptr;
AZ::IO::FileIOBase* m_localFileIO = nullptr;
UnitTest::ScopedTemporaryDirectory* m_tempDir = nullptr;
AZStd::unique_ptr<AZ::SettingsRegistryInterface> m_settingsRegistry;
AZ::IO::Path m_oldEngineRoot;
};
TEST_F(MockUtilsTest, DISABLED_TestFilePath_StartsWithAFileSeparator_Valid)
{
AZStd::string relFilePath = "Foo/foo.xml";
AzFramework::StringFunc::Prepend(relFilePath, AZ_CORRECT_FILESYSTEM_SEPARATOR);
AZStd::string absoluteFilePath;
#if AZ_TRAIT_OS_USE_WINDOWS_FILE_PATHS
AZStd::string driveString;
AzFramework::StringFunc::Path::GetDrive(GetAppRoot(), driveString);
AzFramework::StringFunc::Path::ConstructFull(driveString.c_str(), relFilePath.c_str(), absoluteFilePath, true);
#else
absoluteFilePath = relFilePath;
#endif
FilePath filePath(relFilePath);
AZ::IO::Path relFilePath = "Foo/foo.xml";
AZ::IO::Path absoluteFilePath = AZ::IO::PathView(GetEngineRoot()).RootPath();
absoluteFilePath /= relFilePath;
absoluteFilePath = absoluteFilePath.LexicallyNormal();
FilePath filePath(relFilePath.Native());
EXPECT_STREQ(filePath.AbsolutePath().c_str(), absoluteFilePath.c_str());
}
TEST_F(MockUtilsTest, TestFilePath_RelativePath_Valid)
{
AZStd::string relFilePath = "Foo\\foo.xml";
AZStd::string absoluteFilePath;
AzFramework::StringFunc::Path::ConstructFull(GetAppRoot(), relFilePath.c_str(), absoluteFilePath, true);
FilePath filePath(relFilePath);
EXPECT_EQ(filePath.AbsolutePath(), absoluteFilePath);
AZ::IO::Path relFilePath = "Foo\\foo.xml";
AZ::IO::Path absoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / relFilePath).LexicallyNormal();
FilePath filePath(relFilePath.Native());
EXPECT_EQ(AZ::IO::PathView{ filePath.AbsolutePath() }, absoluteFilePath);
}
#if !AZ_TRAIT_USE_WINDOWS_FILE_API
// When using Windows file API the the AZ::IO::Path comparisons are case insensitive
TEST_F(MockUtilsTest, TestFilePath_CasingMismatch_Error_valid)
{
AZStd::string relFilePath = "Foo\\Foo.xml";
AZStd::string wrongCaseRelFilePath = "Foo\\foo.xml";
AZStd::string correctAbsoluteFilePath;
AZStd::string wrongCaseAbsoluteFilePath;
AzFramework::StringFunc::Path::ConstructFull(GetAppRoot(), relFilePath.c_str(), correctAbsoluteFilePath, true);
AzFramework::StringFunc::Path::ConstructFull(GetAppRoot(), wrongCaseRelFilePath.c_str(), wrongCaseAbsoluteFilePath, true);
AZ::IO::Path relFilePath = "Foo\\Foo.xml";
AZ::IO::Path wrongCaseRelFilePath = "Foo\\foo.xml";
AZ::IO::Path correctAbsoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / relFilePath).LexicallyNormal();
AZ::IO::Path wrongCaseAbsoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / wrongCaseRelFilePath).LexicallyNormal();
AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle;
AZ::IO::FileIOBase::GetInstance()->Open(correctAbsoluteFilePath.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeCreatePath, fileHandle);
FilePath filePath(wrongCaseAbsoluteFilePath, true, false);
FilePath filePath(wrongCaseAbsoluteFilePath.Native(), true, false);
EXPECT_FALSE(filePath.IsValid());
EXPECT_TRUE(filePath.ErrorString().find("File case mismatch") != AZStd::string::npos);
EXPECT_TRUE(filePath.ErrorString().contains("File case mismatch"));
}
#endif
TEST_F(MockUtilsTest, TestFilePath_NoFileExists_NoError_valid)
{
AZStd::string relFilePath = "Foo\\Foo.xml";
AZStd::string absoluteFilePath;
AzFramework::StringFunc::Path::ConstructFull(GetAppRoot(), relFilePath.c_str(), absoluteFilePath, true);
FilePath filePath(absoluteFilePath, true, false);
AZ::IO::Path relFilePath = "Foo\\Foo.xml";
AZ::IO::Path absoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / relFilePath).LexicallyNormal();
FilePath filePath(absoluteFilePath.Native(), true, false);
EXPECT_TRUE(filePath.IsValid());
EXPECT_TRUE(filePath.ErrorString().empty());
}
@@ -119,13 +136,12 @@ namespace AssetBundler
{
AZStd::string relFilePath = "Foo\\Foo.xml";
AZStd::string wrongCaseRelFilePath = "Foo\\foo.xml";
AZStd::string correctAbsoluteFilePath;
AZStd::string wrongCaseAbsoluteFilePath;
AzFramework::StringFunc::Path::ConstructFull(GetAppRoot(), relFilePath.c_str(), correctAbsoluteFilePath, true);
AzFramework::StringFunc::Path::ConstructFull(GetAppRoot(), wrongCaseRelFilePath.c_str(), wrongCaseAbsoluteFilePath, true);
AZ::IO::Path correctAbsoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / relFilePath).LexicallyNormal();
AZ::IO::Path wrongCaseAbsoluteFilePath = (AZ::IO::Path(GetEngineRoot()) / wrongCaseRelFilePath).LexicallyNormal();
AZ::IO::HandleType fileHandle = AZ::IO::InvalidHandle;
AZ::IO::FileIOBase::GetInstance()->Open(correctAbsoluteFilePath.c_str(), AZ::IO::OpenMode::ModeWrite | AZ::IO::OpenMode::ModeCreatePath, fileHandle);
FilePath filePath(wrongCaseAbsoluteFilePath, true, true);
FilePath filePath(wrongCaseAbsoluteFilePath.Native(), true, true);
EXPECT_TRUE(filePath.IsValid());
EXPECT_STREQ(filePath.AbsolutePath().c_str(), correctAbsoluteFilePath.c_str());
}