Integrating latest from github/staging

Integrating up through commit 5e1bdae
This commit is contained in:
alexpete
2021-03-26 14:31:50 -07:00
parent 9c54341af8
commit 36c4e827bd
764 changed files with 11453 additions and 20251 deletions
+19 -10
View File
@@ -11,7 +11,9 @@
*/
#include "FrameworkApplicationFixture.h"
#include <AzFramework/StringFunc/StringFunc.h>
#include <AzCore/IO/FileIO.h>
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
#include <AzCore/StringFunc/StringFunc.h>
#include <AzTest/Utils.h>
class ApplicationTest
@@ -22,7 +24,14 @@ protected:
void SetUp() override
{
FrameworkApplicationFixture::SetUp();
m_application->SetAssetRoot(m_tempDirectory.GetDirectory());
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
{
settingsRegistry->Set(AZ::SettingsRegistryMergeUtils::FilePathKey_CacheRootFolder, m_tempDirectory.GetDirectory());
}
if (auto fileIoBase = AZ::IO::FileIOBase::GetInstance(); fileIoBase != nullptr)
{
fileIoBase->SetAlias("@assets@", m_tempDirectory.GetDirectory());
}
}
void TearDown() override
@@ -31,13 +40,13 @@ protected:
}
AZStd::string m_root;
AZ::Test::ScopedAutoTempDirectory m_tempDirectory;
AZ::Test::ScopedAutoTempDirectory m_tempDirectory;
};
TEST_F(ApplicationTest, MakePathAssetRootRelative_AbsPath_Valid)
{
AZStd::string inputPath;
AzFramework::StringFunc::Path::ConstructFull(m_tempDirectory.GetDirectory(), "TestA.txt", inputPath, true);
AZ::StringFunc::Path::ConstructFull(m_tempDirectory.GetDirectory(), "TestA.txt", inputPath, true);
m_application->MakePathAssetRootRelative(inputPath);
EXPECT_EQ(inputPath, "testa.txt");
}
@@ -45,7 +54,7 @@ TEST_F(ApplicationTest, MakePathAssetRootRelative_AbsPath_Valid)
TEST_F(ApplicationTest, MakePathRelative_AbsPath_Valid)
{
AZStd::string inputPath;
AzFramework::StringFunc::Path::ConstructFull(m_tempDirectory.GetDirectory(), "TestA.txt", inputPath, true);
AZ::StringFunc::Path::ConstructFull(m_tempDirectory.GetDirectory(), "TestA.txt", inputPath, true);
m_application->MakePathRelative(inputPath, m_tempDirectory.GetDirectory());
EXPECT_EQ(inputPath, "TestA.txt");
}
@@ -55,7 +64,7 @@ TEST_F(ApplicationTest, MakePathAssetRootRelative_AbsPath_RootLowerCase_Valid)
AZStd::string inputPath;
AZStd::string root = m_tempDirectory.GetDirectory();
AZStd::to_lower(root.begin(), root.end());
AzFramework::StringFunc::Path::ConstructFull(root.c_str(), "TestA.txt", inputPath, true);
AZ::StringFunc::Path::ConstructFull(root.c_str(), "TestA.txt", inputPath, true);
m_application->MakePathAssetRootRelative(inputPath);
EXPECT_EQ(inputPath, "testa.txt");
}
@@ -65,7 +74,7 @@ TEST_F(ApplicationTest, MakePathRelative_AbsPath_RootLowerCase_Valid)
AZStd::string inputPath;
AZStd::string root = m_tempDirectory.GetDirectory();
AZStd::to_lower(root.begin(), root.end());
AzFramework::StringFunc::Path::ConstructFull(root.c_str(), "TestA.txt", inputPath, true);
AZ::StringFunc::Path::ConstructFull(root.c_str(), "TestA.txt", inputPath, true);
m_application->MakePathRelative(inputPath, root.c_str());
EXPECT_EQ(inputPath, "TestA.txt");
}
@@ -74,7 +83,7 @@ TEST_F(ApplicationTest, MakePathRelative_AbsPath_RootLowerCase_Valid)
TEST_F(ApplicationTest, MakePathAssetRootRelative_AbsPathWithSubFolders_Valid)
{
AZStd::string inputPath;
AzFramework::StringFunc::Path::ConstructFull(m_tempDirectory.GetDirectory(), "Foo/TestA.txt", inputPath, true);
AZ::StringFunc::Path::ConstructFull(m_tempDirectory.GetDirectory(), "Foo/TestA.txt", inputPath, true);
m_application->MakePathAssetRootRelative(inputPath);
EXPECT_EQ(inputPath, "foo/testa.txt");
}
@@ -82,7 +91,7 @@ TEST_F(ApplicationTest, MakePathAssetRootRelative_AbsPathWithSubFolders_Valid)
TEST_F(ApplicationTest, MakePathRelative_AbsPathWithSubFolders_Valid)
{
AZStd::string inputPath;
AzFramework::StringFunc::Path::ConstructFull(m_tempDirectory.GetDirectory(), "Foo/TestA.txt", inputPath, true);
AZ::StringFunc::Path::ConstructFull(m_tempDirectory.GetDirectory(), "Foo/TestA.txt", inputPath, true);
m_application->MakePathRelative(inputPath, m_tempDirectory.GetDirectory());
EXPECT_EQ(inputPath, "Foo/TestA.txt");
}
@@ -141,4 +150,4 @@ TEST_F(ApplicationTest, MakePathRelative_RelPathWithSubFolderStartingWithSeparat
AZStd::string inputPath("//Foo/TestA.txt");
m_application->MakePathRelative(inputPath, m_tempDirectory.GetDirectory());
EXPECT_EQ(inputPath, "Foo/TestA.txt");
}
}
@@ -76,7 +76,7 @@ namespace UnitTest
TEST_P(ArchiveCompressionTestFixture, TestArchivePacking_CompressionEmptyArchiveTest_PackIsValid)
{
// this also coincidentally tests to make sure packs inside aliases work.
AZStd::string testArchivePath = "@cache@/archivetest.pak";
AZStd::string testArchivePath = "@usercache@/archivetest.pak";
AZ::IO::FileIOBase* fileIo = AZ::IO::FileIOBase::GetInstance();
ASSERT_NE(nullptr, fileIo);
@@ -99,7 +99,7 @@ namespace UnitTest
TEST_P(ArchiveCompressionTestFixture, TestArchivePacking_CompressionFullArchive_PackIsValid)
{
// ------------ BASIC TEST: Create archive full of standard sizes (including 0) ----------------
AZStd::string testArchivePath = "@cache@/archivetest.pak";
AZStd::string testArchivePath = "@usercache@/archivetest.pak";
AZ::IO::IArchive* archive = AZ::Interface<AZ::IO::IArchive>::Get();
auto openFlags = AZStd::get<0>(GetParam());
@@ -165,7 +165,7 @@ namespace UnitTest
TEST_P(ArchiveCompressionTestFixture, TestArchivePacking_CompressionWithOverridenArchiveData_PackIsValid)
{
// ---------------- MORE COMPLICATED TEST which involves overwriting elements ----------------
AZStd::string testArchivePath = "@cache@/archivetest.pak";
AZStd::string testArchivePath = "@usercache@/archivetest.pak";
AZ::IO::IArchive* archive = AZ::Interface<AZ::IO::IArchive>::Get();
auto openFlags = AZStd::get<0>(GetParam());
@@ -275,7 +275,7 @@ namespace UnitTest
// we want to make at least one element shrink and one element grow, adjacent to other files
// this will include files that become zero size, and also includes new files that were not there before
AZStd::string testArchivePath = "@cache@/archivetest.pak";
AZStd::string testArchivePath = "@usercache@/archivetest.pak";
AZ::IO::IArchive* archive = AZ::Interface<AZ::IO::IArchive>::Get();
auto openFlags = AZStd::get<0>(GetParam());
+18 -18
View File
@@ -240,14 +240,14 @@ namespace UnitTest
ASSERT_NE(nullptr, console);
{
AZStd::string testArchivePath_withSubfolders = "@cache@/immediate.pak";
AZStd::string testArchivePath_withMountPoint = "@cache@/levels/test/flatarchive.pak";
AZStd::string testArchivePath_withSubfolders = "@usercache@/immediate.pak";
AZStd::string testArchivePath_withMountPoint = "@usercache@/levels/test/flatarchive.pak";
// delete test files in case they already exist
archive->ClosePack(testArchivePath_withSubfolders.c_str());
fileIo->Remove(testArchivePath_withSubfolders.c_str());
fileIo->Remove(testArchivePath_withMountPoint.c_str());
fileIo->CreatePath("@cache@/levels/test");
fileIo->CreatePath("@usercache@/levels/test");
// setup test archive and file
AZStd::intrusive_ptr<AZ::IO::INestedArchive> pArchive = archive->OpenArchive(testArchivePath_withSubfolders.c_str(), nullptr, AZ::IO::INestedArchive::FLAGS_CREATE_NEW);
@@ -314,14 +314,14 @@ namespace UnitTest
// and be able to IMMEDIATELY
// * read the file in the subfolder
// * enumerate the folders (including that subfolder) even though they are 'virtual', not real folders on physical media
// * all of the above even though the mount point for the archive is @assets@ wheras the physical pack lives in @cache@
// * all of the above even though the mount point for the archive is @assets@ wheras the physical pack lives in @usercache@
// finally, we're going to repeat the above test but with files mounted with subfolders
// so for example, the pack will contain levelinfo.xml at the root of it
// but it will be mounted at a subfolder (levels/mylevel).
// this must cause FindNext and Open to work for levels/mylevel/levelinfo.xml.
constexpr const char* testArchivePath_withSubfolders = "@cache@/immediate.pak";
constexpr const char* testArchivePath_withMountPoint = "@cache@/levels/test/flatarchive.pak";
constexpr const char* testArchivePath_withSubfolders = "@usercache@/immediate.pak";
constexpr const char* testArchivePath_withMountPoint = "@usercache@/levels/test/flatarchive.pak";
AZ::IO::FileIOBase* fileIo = AZ::IO::FileIOBase::GetInstance();
ASSERT_NE(nullptr, fileIo);
@@ -340,7 +340,7 @@ namespace UnitTest
archive->ClosePack(testArchivePath_withMountPoint);
fileIo->Remove(testArchivePath_withSubfolders);
fileIo->Remove(testArchivePath_withMountPoint);
fileIo->CreatePath("@cache@/levels/test");
fileIo->CreatePath("@usercache@/levels/test");
AZStd::intrusive_ptr<AZ::IO::INestedArchive> pArchive = archive->OpenArchive(testArchivePath_withSubfolders, {}, AZ::IO::INestedArchive::FLAGS_CREATE_NEW);
@@ -435,7 +435,7 @@ namespace UnitTest
ASSERT_NE(nullptr, archive);
constexpr AZStd::string_view dataString = "HELLO WORLD";
constexpr const char* testArchivePath_withMountPoint = "@cache@/levels/test/flatarchive.pak";
constexpr const char* testArchivePath_withMountPoint = "@usercache@/levels/test/flatarchive.pak";
bool found_mylevel_file{};
bool found_mylevel_folder{};
@@ -556,10 +556,10 @@ namespace UnitTest
// mount the pack
// make sure that the pack and loose file both appear when the PaKFileIO interface is used.
using namespace AZ::IO;
AZ::IO::IArchive* archive = AZ::Interface<AZ::IO::IArchive>::Get();;
AZ::IO::IArchive* archive = AZ::Interface<AZ::IO::IArchive>::Get();
AZ::IO::ArchiveFileIO cpfio(archive);
constexpr const char* genericArchiveFileName = "@cache@/testarchiveio.pak";
constexpr const char* genericArchiveFileName = "@usercache@/testarchiveio.pak";
ASSERT_NE(nullptr, archive);
const char* dataString = "HELLO WORLD"; // other unit tests make sure writing and reading is working, so don't test that here
size_t dataLen = strlen(dataString);
@@ -599,7 +599,7 @@ namespace UnitTest
EXPECT_TRUE(cpfio.Exists("testfile.xml"));
EXPECT_TRUE(cpfio.Exists("@assets@/testfile.xml")); // this should be hte same file
EXPECT_TRUE(!cpfio.Exists("@log@/testfile.xml"));
EXPECT_TRUE(!cpfio.Exists("@cache@/testfile.xml"));
EXPECT_TRUE(!cpfio.Exists("@usercache@/testfile.xml"));
EXPECT_TRUE(cpfio.Exists("@log@/unittesttemp/realfileforunittest.xml"));
// --- Coverage test ----
@@ -715,7 +715,7 @@ namespace UnitTest
ASSERT_NE(nullptr, fileIo);
// test whether aliasing works as expected. We'll create a archive in the cache, but we'll map it to a bunch of folders
constexpr const char* testArchivePath = "@cache@/archivetest.pak";
constexpr const char* testArchivePath = "@usercache@/archivetest.pak";
char realNameBuf[AZ_MAX_PATH_LEN] = { 0 };
EXPECT_TRUE(fileIo->ResolvePath(testArchivePath, realNameBuf, AZ_MAX_PATH_LEN));
@@ -737,16 +737,16 @@ namespace UnitTest
pArchive.reset();
EXPECT_TRUE(IsPackValid(testArchivePath));
EXPECT_TRUE(archive->OpenPack("@cache@", realNameBuf));
EXPECT_TRUE(archive->IsFileExist("@cache@/foundit.dat"));
EXPECT_FALSE(archive->IsFileExist("@cache@/foundit.dat", AZ::IO::IArchive::eFileLocation_OnDisk));
EXPECT_FALSE(archive->IsFileExist("@cache@/notfoundit.dat"));
EXPECT_TRUE(archive->OpenPack("@usercache@", realNameBuf));
EXPECT_TRUE(archive->IsFileExist("@usercache@/foundit.dat"));
EXPECT_FALSE(archive->IsFileExist("@usercache@/foundit.dat", AZ::IO::IArchive::eFileLocation_OnDisk));
EXPECT_FALSE(archive->IsFileExist("@usercache@/notfoundit.dat"));
EXPECT_TRUE(archive->ClosePack(realNameBuf));
// change its actual location:
EXPECT_TRUE(archive->OpenPack("@assets@", realNameBuf));
EXPECT_TRUE(archive->IsFileExist("@assets@/foundit.dat"));
EXPECT_FALSE(archive->IsFileExist("@cache@/foundit.dat")); // do not find it in the previous location!
EXPECT_FALSE(archive->IsFileExist("@usercache@/foundit.dat")); // do not find it in the previous location!
EXPECT_FALSE(archive->IsFileExist("@assets@/foundit.dat", AZ::IO::IArchive::eFileLocation_OnDisk));
EXPECT_FALSE(archive->IsFileExist("@assets@/notfoundit.dat"));
EXPECT_TRUE(archive->ClosePack(realNameBuf));
@@ -755,7 +755,7 @@ namespace UnitTest
EXPECT_TRUE(archive->OpenPack("@assets@/mystuff", realNameBuf));
EXPECT_TRUE(archive->IsFileExist("@assets@/mystuff/foundit.dat"));
EXPECT_FALSE(archive->IsFileExist("@assets@/foundit.dat")); // do not find it in the previous locations!
EXPECT_FALSE(archive->IsFileExist("@cache@/foundit.dat")); // do not find it in the previous locations!
EXPECT_FALSE(archive->IsFileExist("@usercache@/foundit.dat")); // do not find it in the previous locations!
EXPECT_FALSE(archive->IsFileExist("@assets@/foundit.dat", AZ::IO::IArchive::eFileLocation_OnDisk));
EXPECT_FALSE(archive->IsFileExist("@assets@/mystuff/foundit.dat", AZ::IO::IArchive::eFileLocation_OnDisk));
EXPECT_FALSE(archive->IsFileExist("@assets@/notfoundit.dat")); // non-existent file
-1
View File
@@ -842,7 +842,6 @@ namespace UnitTest
m_application = new AzFramework::Application();
m_assetRoot = UnitTest::GetTestFolderPath();
m_application->NormalizePathKeepCase(m_assetRoot);
m_application->SetAssetRoot(m_assetRoot.c_str());
m_assetCatalog = aznew AzFramework::AssetCatalog();
m_firstAssetId = AssetId(AZ::Uuid::CreateRandom(), 0);
+2 -1
View File
@@ -1105,8 +1105,9 @@ namespace UnitTest
SerializeContext* GetSerializeContext() override { return m_serializeContext.get(); }
BehaviorContext* GetBehaviorContext() override { return nullptr; }
JsonRegistrationContext* GetJsonRegistrationContext() override { return nullptr; }
const char* GetExecutableFolder() const override { return nullptr; }
const char* GetAppRoot() const override { return nullptr; }
const char* GetEngineRoot() const override { return nullptr; }
const char* GetExecutableFolder() const override { return nullptr; }
Debug::DrillerManager* GetDrillerManager() override { return nullptr; }
void EnumerateEntities(const EntityCallback& /*callback*/) override {}
void QueryApplicationType(AZ::ApplicationTypeQuery& /*appType*/) const override {}
-1
View File
@@ -184,7 +184,6 @@ namespace UnitTest
AzToolsFramework::Components::PropertyManagerComponent::CreateDescriptor();
const char* dir = m_componentApplication->GetExecutableFolder();
m_componentApplication->SetAssetRoot(dir);
m_localFileIO.SetAlias("@assets@", dir);
m_localFileIO.SetAlias("@devassets@", dir);
+1
View File
@@ -283,6 +283,7 @@ namespace UnitTest
MOCK_METHOD0(GetBehaviorContext, AZ::BehaviorContext* ());
MOCK_METHOD0(GetJsonRegistrationContext, AZ::JsonRegistrationContext* ());
MOCK_CONST_METHOD0(GetAppRoot, const char* ());
MOCK_CONST_METHOD0(GetEngineRoot, const char* ());
MOCK_CONST_METHOD0(GetExecutableFolder, const char* ());
MOCK_METHOD0(GetDrillerManager, AZ::Debug::DrillerManager* ());
MOCK_METHOD0(GetTickDeltaTime, float ());
+5 -6
View File
@@ -17,17 +17,16 @@
void OutputArgs(const AzFramework::CommandLine& commandLine)
{
const AzFramework::CommandLine::ParamMap& switchList = commandLine.GetSwitchList();
std::cout << "Switch List:" << std::endl;
for (auto& switchPair : switchList)
for (auto& switchPair : commandLine)
{
// We strip white space from all of our switch names, so "flush" names will start arguments
std::cout << switchPair.first.c_str() << std::endl;
for (auto& switchValue : switchPair.second)
if (!switchPair.m_option.empty())
{
// Auto space every switch value by one space
std::cout << " " << switchValue.c_str() << std::endl;
std::cout << switchPair.m_option.c_str() << std::endl;
}
std::cout << " " << switchPair.m_value.c_str() << std::endl;
}
std::cout << "End Switch List:" << std::endl;
}
@@ -12,8 +12,8 @@
#include <AzCore/UnitTest/TestTypes.h>
#include <AzFramework/CommandLine/CommandLine.h>
#include <AzToolsFramework/Process/ProcessWatcher.h>
#include <AzToolsFramework/Process/ProcessCommunicator.h>
#include <AzFramework/Process/ProcessWatcher.h>
#include <AzFramework/Process/ProcessCommunicator.h>
#include <AzCore/std/containers/vector.h>
#include <AzCore/std/string/string.h>
#include <AzCore/std/containers/unordered_map.h>
@@ -76,13 +76,13 @@ namespace UnitTest
TEST_F(ProcessLaunchParseTests, ProcessLauncher_LaunchBasicProcess_Success)
{
AzToolsFramework::ProcessOutput processOutput;
AzToolsFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
AzFramework::ProcessOutput processOutput;
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
processLaunchInfo.m_commandlineParameters = AZ_TRAIT_TEST_ROOT_FOLDER "ProcessLaunchTest";
processLaunchInfo.m_workingDirectory = AZ::Test::GetCurrentExecutablePath();
processLaunchInfo.m_showWindow = false;
bool launchReturn = AzToolsFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzToolsFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
bool launchReturn = AzFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
EXPECT_EQ(launchReturn, true);
EXPECT_EQ(processOutput.outputResult.empty(), false);
@@ -91,13 +91,13 @@ namespace UnitTest
TEST_F(ProcessLaunchParseTests, ProcessLauncher_BasicParameter_Success)
{
ProcessLaunchParseTests::ParsedArgMap argMap;
AzToolsFramework::ProcessOutput processOutput;
AzToolsFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
AzFramework::ProcessOutput processOutput;
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
processLaunchInfo.m_commandlineParameters = AZ_TRAIT_TEST_ROOT_FOLDER "ProcessLaunchTest -param1 param1val -param2=param2val";
processLaunchInfo.m_workingDirectory = AZ::Test::GetCurrentExecutablePath();
processLaunchInfo.m_showWindow = false;
bool launchReturn = AzToolsFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzToolsFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
bool launchReturn = AzFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
EXPECT_EQ(launchReturn, true);
@@ -125,13 +125,13 @@ namespace UnitTest
#endif // AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS
{
ProcessLaunchParseTests::ParsedArgMap argMap;
AzToolsFramework::ProcessOutput processOutput;
AzToolsFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
AzFramework::ProcessOutput processOutput;
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
processLaunchInfo.m_commandlineParameters = AZ_TRAIT_TEST_ROOT_FOLDER R"(ProcessLaunchTest -param1 "\"param,1val\"" -param2="\"param2v,al\"")";
processLaunchInfo.m_workingDirectory = AZ::Test::GetCurrentExecutablePath();
processLaunchInfo.m_showWindow = false;
bool launchReturn = AzToolsFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzToolsFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
bool launchReturn = AzFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
EXPECT_EQ(launchReturn, true);
@@ -159,13 +159,13 @@ namespace UnitTest
#endif // AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS
{
ProcessLaunchParseTests::ParsedArgMap argMap;
AzToolsFramework::ProcessOutput processOutput;
AzToolsFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
AzFramework::ProcessOutput processOutput;
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
processLaunchInfo.m_commandlineParameters = AZ_TRAIT_TEST_ROOT_FOLDER R"(ProcessLaunchTest -param1 "\"param 1val\"" -param2="\"param2v al\"")";
processLaunchInfo.m_workingDirectory = AZ::Test::GetCurrentExecutablePath();
processLaunchInfo.m_showWindow = false;
bool launchReturn = AzToolsFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzToolsFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
bool launchReturn = AzFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
EXPECT_EQ(launchReturn, true);
@@ -193,13 +193,13 @@ namespace UnitTest
#endif // AZ_TRAIT_DISABLE_FAILED_PROCESS_LAUNCHER_TESTS
{
ProcessLaunchParseTests::ParsedArgMap argMap;
AzToolsFramework::ProcessOutput processOutput;
AzToolsFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
AzFramework::ProcessOutput processOutput;
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
processLaunchInfo.m_commandlineParameters = AZ_TRAIT_TEST_ROOT_FOLDER R"(ProcessLaunchTest -param1 "\"par,am 1val\"" -param2="\"param,2v al\"")";
processLaunchInfo.m_workingDirectory = AZ::Test::GetCurrentExecutablePath();
processLaunchInfo.m_showWindow = false;
bool launchReturn = AzToolsFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzToolsFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
bool launchReturn = AzFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
EXPECT_EQ(launchReturn, true);
@@ -223,13 +223,13 @@ namespace UnitTest
TEST_F(ProcessLaunchParseTests, ProcessLauncher_CommaStringNoQuotes_Success)
{
ProcessLaunchParseTests::ParsedArgMap argMap;
AzToolsFramework::ProcessOutput processOutput;
AzToolsFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
AzFramework::ProcessOutput processOutput;
AzFramework::ProcessLauncher::ProcessLaunchInfo processLaunchInfo;
processLaunchInfo.m_commandlineParameters = AZ_TRAIT_TEST_ROOT_FOLDER "ProcessLaunchTest -param1 param,1val -param2=param2v,al";
processLaunchInfo.m_workingDirectory = AZ::Test::GetCurrentExecutablePath();
processLaunchInfo.m_showWindow = false;
bool launchReturn = AzToolsFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzToolsFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
bool launchReturn = AzFramework::ProcessWatcher::LaunchProcessAndRetrieveOutput(processLaunchInfo, AzFramework::ProcessCommunicationType::COMMUNICATOR_TYPE_STDINOUT, processOutput);
EXPECT_EQ(launchReturn, true);
@@ -1,314 +0,0 @@
/*
* 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 <AzTest/AzTest.h>
#include <AzFramework/ProjectManager/ProjectManager.h>
#include <AzCore/IO/SystemFile.h>
#include <Utils/Utils.h>
namespace ProjectManagerTests
{
////////////////////////////////////////////////////////////////////////////////////////////////
class ProjectManagerTest : public ::testing::Test
{
protected:
////////////////////////////////////////////////////////////////////////////////////////////
void SetUp() override
{
}
////////////////////////////////////////////////////////////////////////////////////////////
void TearDown() override
{
}
};
////////////////////////////////////////////////////////////////////////////////////////////////
class ProjectManagerBootstrapTest : public ::testing::Test
{
protected:
////////////////////////////////////////////////////////////////////////////////////////////
void SetUp() override
{
AZ::IO::SystemFile engineFile;
AZ::IO::FixedMaxPath engineFilePath(m_tempDir.GetDirectory());
m_projectPath = engineFilePath / "TestProject";
AZ::IO::SystemFile::CreateDir(m_projectPath.c_str());
engineFilePath = engineFilePath / "engine.json";
engineFile.Open(engineFilePath.c_str(), AZ::IO::SystemFile::SF_OPEN_CREATE);
engineFile.Close();
}
////////////////////////////////////////////////////////////////////////////////////////////
void TearDown() override
{
}
AZ::IO::FixedMaxPath m_projectPath;
UnitTest::ScopedTemporaryDirectory m_tempDir;
};
////////////////////////////////////////////////////////////////////////////////////////////////
TEST_F(ProjectManagerTest, HasProjectNameTest_ProjectNameGivenWithDash_Success)
{
constexpr int numArguments = 2;
static const char* argumentList1[numArguments] = { "C:/somepath/to/exe", "-projectpath" };
EXPECT_TRUE(AzFramework::ProjectManager::HasCommandLineProjectName(numArguments, const_cast<char**>(argumentList1)));
static const char* argumentList2[numArguments] = { "C:/somepath/to/exe", "--projectpath" };
EXPECT_TRUE(AzFramework::ProjectManager::HasCommandLineProjectName(numArguments, const_cast<char**>(argumentList2)));
static const char* argumentList3[numArguments] = { "C:/somepath/to/exe", "/projectpath" };
EXPECT_TRUE(AzFramework::ProjectManager::HasCommandLineProjectName(numArguments, const_cast<char**>(argumentList3)));
}
TEST_F(ProjectManagerTest, HasProjectNameTest_ProjectNameGivenWithRegSet_Success)
{
constexpr int numArguments = 2;
static const char* argumentList1[numArguments] = { "C:/somepath/to/exe", "-regset=\"/Amazon/AzCore/Bootstrap/sys_game_folder=SomeFolder\"" };
EXPECT_TRUE(AzFramework::ProjectManager::HasCommandLineProjectName(numArguments, const_cast<char**>(argumentList1)));
static const char* argumentList2[numArguments] = { "C:/somepath/to/exe", "--regset=\"/Amazon/AzCore/Bootstrap/sys_game_folder=SomeFolder\"" };
EXPECT_TRUE(AzFramework::ProjectManager::HasCommandLineProjectName(numArguments, const_cast<char**>(argumentList2)));
static const char* argumentList3[numArguments] = { "C:/somepath/to/exe", "/regset=\"/Amazon/AzCore/Bootstrap/sys_game_folder=SomeFolder\"" };
EXPECT_TRUE(AzFramework::ProjectManager::HasCommandLineProjectName(numArguments, const_cast<char**>(argumentList3)));
}
TEST_F(ProjectManagerTest, HasProjectNameTest_ProjectNameGivenWithImroperPrefixes_Fails)
{
constexpr int numArguments = 2;
static const char* argumentList1[numArguments] = { "C:/somepath/to/exe", "projectpath" };
EXPECT_FALSE(AzFramework::ProjectManager::HasCommandLineProjectName(numArguments, const_cast<char**>(argumentList1)));
static const char* argumentList2[numArguments] = { "C:/somepath/to/exe", "---projectpath" };
EXPECT_FALSE(AzFramework::ProjectManager::HasCommandLineProjectName(numArguments, const_cast<char**>(argumentList2)));
static const char* argumentList3[numArguments] = { "C:/somepath/to/exe", "//projectpath" };
EXPECT_FALSE(AzFramework::ProjectManager::HasCommandLineProjectName(numArguments, const_cast<char**>(argumentList3)));
static const char* argumentList4[numArguments] = { "C:/somepath/to/exe", "pprojectpath" };
EXPECT_FALSE(AzFramework::ProjectManager::HasCommandLineProjectName(numArguments, const_cast<char**>(argumentList4)));
}
////////////////////////////////////////////////////////////////////////////////////////////////
TEST_F(ProjectManagerTest, HasProjectNameTest_ProjectNameNotGiven_Fails)
{
constexpr int numArguments = 2;
static const char* argumentList[numArguments] = { "C:/somepath/to/exe", "someotherparam" };
EXPECT_FALSE(AzFramework::ProjectManager::HasCommandLineProjectName(numArguments, const_cast<char**>(argumentList)));
}
////////////////////////////////////////////////////////////////////////////////////////////////
TEST_F(ProjectManagerTest, HasProjectNameTest_NoAdditionalParams_Fails)
{
constexpr int numArguments = 1;
static const char* argumentList[numArguments] = { "C:/somepath/to/exe" };
EXPECT_FALSE(AzFramework::ProjectManager::HasCommandLineProjectName(numArguments, const_cast<char**>(argumentList)));
}
////////////////////////////////////////////////////////////////////////////////////////////////
TEST_F(ProjectManagerTest, ContentTest_HasValidProjectName_Passes)
{
AZStd::fixed_string<AzFramework::ProjectManager::MaxBootstrapFileSize> testContent =
R"(-- When you see an option that does not have a platform preceeding it, that is the default
--value for anything not specificly set per platform.So if remote_filesystem = 0 and you have
-- ios_remote_file_system = 1 then remote filesystem will be off for all platforms except ios
-- Any of the settings in this file can be prefixed with a platform name :
--android, ios, mac, linux, windows, etc...
-- or left unprefixed, to set all platforms not specified.The rules apply in the order they're declared
sys_game_folder=SamplesProject
-- remote_filesystem - enable Virtual File System(VFS)
--This feature allows a remote instance of the game to run off assets
-- on the asset processor computers cache instead of deploying them the remote device
-- By default it is offand can be overridden for any platform)";
EXPECT_TRUE(AzFramework::ProjectManager::ContentHasProjectName(testContent));
}
TEST_F(ProjectManagerTest, ContentTest_HasValidProjectNameSpaced_Passes)
{
AZStd::fixed_string<AzFramework::ProjectManager::MaxBootstrapFileSize> testContent =
R"(-- When you see an option that does not have a platform preceeding it, that is the default
--value for anything not specificly set per platform.So if remote_filesystem = 0 and you have
-- ios_remote_file_system = 1 then remote filesystem will be off for all platforms except ios
-- Any of the settings in this file can be prefixed with a platform name :
--android, ios, mac, linux, windows, etc...
-- or left unprefixed, to set all platforms not specified.The rules apply in the order they're declared
sys_game_folder = SamplesProject
-- remote_filesystem - enable Virtual File System(VFS)
--This feature allows a remote instance of the game to run off assets
-- on the asset processor computers cache instead of deploying them the remote device
-- By default it is offand can be overridden for any platform)";
EXPECT_TRUE(AzFramework::ProjectManager::ContentHasProjectName(testContent));
}
TEST_F(ProjectManagerTest, ContentTest_HasNoProjectName_Fails)
{
AZStd::fixed_string<AzFramework::ProjectManager::MaxBootstrapFileSize> testContent =
R"(-- When you see an option that does not have a platform preceeding it, that is the default
--value for anything not specificly set per platform.So if remote_filesystem = 0 and you have
-- ios_remote_file_system = 1 then remote filesystem will be off for all platforms except ios
-- Any of the settings in this file can be prefixed with a platform name :
--android, ios, mac, linux, windows, etc...
-- or left unprefixed, to set all platforms not specified.The rules apply in the order they're declared
sys_game_folder=
-- remote_filesystem - enable Virtual File System(VFS)
--This feature allows a remote instance of the game to run off assets
-- on the asset processor computers cache instead of deploying them the remote device
-- By default it is offand can be overridden for any platform)";
EXPECT_FALSE(AzFramework::ProjectManager::ContentHasProjectName(testContent));
}
TEST_F(ProjectManagerTest, ContentTest_HasCommentedProjectName_Fails)
{
AZStd::fixed_string<AzFramework::ProjectManager::MaxBootstrapFileSize> testContent =
R"(-- When you see an option that does not have a platform preceeding it, that is the default
--value for anything not specificly set per platform.So if remote_filesystem = 0 and you have
-- ios_remote_file_system = 1 then remote filesystem will be off for all platforms except ios
-- Any of the settings in this file can be prefixed with a platform name :
--android, ios, mac, linux, windows, etc...
-- or left unprefixed, to set all platforms not specified.The rules apply in the order they're declared
-sys_game_folder=SamplesProject
-- remote_filesystem - enable Virtual File System(VFS)
--This feature allows a remote instance of the game to run off assets
-- on the asset processor computers cache instead of deploying them the remote device
-- By default it is offand can be overridden for any platform)";
EXPECT_FALSE(AzFramework::ProjectManager::ContentHasProjectName(testContent));
}
TEST_F(ProjectManagerTest, ContentTest_HasCommentedThenValidProjectName_Passes)
{
AZStd::fixed_string<AzFramework::ProjectManager::MaxBootstrapFileSize> testContent =
R"(-- When you see an option that does not have a platform preceeding it, that is the default
--value for anything not specificly set per platform.So if remote_filesystem = 0 and you have
-- ios_remote_file_system = 1 then remote filesystem will be off for all platforms except ios
-- Any of the settings in this file can be prefixed with a platform name :
--android, ios, mac, linux, windows, etc...
-- or left unprefixed, to set all platforms not specified.The rules apply in the order they're declared
-sys_game_folder=SamplesProject
sys_game_folder=SamplesProject
-- remote_filesystem - enable Virtual File System(VFS)
--This feature allows a remote instance of the game to run off assets
-- on the asset processor computers cache instead of deploying them the remote device
-- By default it is offand can be overridden for any platform)";
EXPECT_TRUE(AzFramework::ProjectManager::ContentHasProjectName(testContent));
}
TEST_F(ProjectManagerTest, ContentTest_OnlyHasValidKey_Passes)
{
AZStd::fixed_string<AzFramework::ProjectManager::MaxBootstrapFileSize> testContent =
R"(sys_game_folder=SamplesProject)";
EXPECT_TRUE(AzFramework::ProjectManager::ContentHasProjectName(testContent));
}
TEST_F(ProjectManagerTest, ContentTest_OnlyHasValidKeyNewline_Passes)
{
AZStd::fixed_string<AzFramework::ProjectManager::MaxBootstrapFileSize> testContent =
R"(sys_game_folder=SamplesProject
)";
EXPECT_TRUE(AzFramework::ProjectManager::ContentHasProjectName(testContent));
}
TEST_F(ProjectManagerTest, ContentTest_EmptyContent_Failse)
{
AZStd::fixed_string<AzFramework::ProjectManager::MaxBootstrapFileSize> testContent;
EXPECT_FALSE(AzFramework::ProjectManager::ContentHasProjectName(testContent));
}
#if AZ_TRAIT_DISABLE_FAILED_FRAMEWORK_TESTS
TEST_F(ProjectManagerBootstrapTest, DISABLED_BootstrapContentTest_HasValidProjectName_Passes)
#else
TEST_F(ProjectManagerBootstrapTest, BootstrapContentTest_HasValidProjectName_Passes)
#endif // AZ_TRAIT_DISABLE_FAILED_FRAMEWORK_TESTS
{
AZStd::fixed_string<AzFramework::ProjectManager::MaxBootstrapFileSize> testContent =
R"(-- When you see an option that does not have a platform preceeding it, that is the default
--value for anything not specificly set per platform.So if remote_filesystem = 0 and you have
-- ios_remote_file_system = 1 then remote filesystem will be off for all platforms except ios
-- Any of the settings in this file can be prefixed with a platform name :
--android, ios, mac, linux, windows, etc...
-- or left unprefixed, to set all platforms not specified.The rules apply in the order they're declared
sys_game_folder=SamplesProject
-- remote_filesystem - enable Virtual File System(VFS)
--This feature allows a remote instance of the game to run off assets
-- on the asset processor computers cache instead of deploying them the remote device
-- By default it is offand can be overridden for any platform)";
AZ::IO::SystemFile bootstrapFile;
AZ::IO::FixedMaxPath bootstrapPath(m_tempDir.GetDirectory());
bootstrapPath /= "bootstrap.cfg";
bootstrapFile.Open(bootstrapPath.c_str(), AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY | AZ::IO::SystemFile::SF_OPEN_CREATE);
bootstrapFile.Write(testContent.data(), testContent.length());
bootstrapFile.Close();
EXPECT_TRUE(AzFramework::ProjectManager::HasBootstrapProjectName(m_projectPath.c_str()));
}
#if AZ_TRAIT_DISABLE_FAILED_FRAMEWORK_TESTS
TEST_F(ProjectManagerBootstrapTest, DISABLED_BootstrapContentTest_HasNoValidProjectName_Fails)
#else
TEST_F(ProjectManagerBootstrapTest, BootstrapContentTest_HasNoValidProjectName_Fails)
#endif // AZ_TRAIT_DISABLE_FAILED_FRAMEWORK_TESTS
{
AZStd::fixed_string<AzFramework::ProjectManager::MaxBootstrapFileSize> testContent =
R"(-- When you see an option that does not have a platform preceeding it, that is the default
--value for anything not specificly set per platform.So if remote_filesystem = 0 and you have
-- ios_remote_file_system = 1 then remote filesystem will be off for all platforms except ios
-- Any of the settings in this file can be prefixed with a platform name :
--android, ios, mac, linux, windows, etc...
-- or left unprefixed, to set all platforms not specified.The rules apply in the order they're declared
sys_game_folder=
-- remote_filesystem - enable Virtual File System(VFS)
--This feature allows a remote instance of the game to run off assets
-- on the asset processor computers cache instead of deploying them the remote device
-- By default it is offand can be overridden for any platform)";
AZ::IO::SystemFile bootstrapFile;
AZ::IO::FixedMaxPath bootstrapPath(m_tempDir.GetDirectory());
bootstrapPath /= "bootstrap.cfg";
bootstrapFile.Open(bootstrapPath.c_str(), AZ::IO::SystemFile::SF_OPEN_WRITE_ONLY | AZ::IO::SystemFile::SF_OPEN_CREATE);
bootstrapFile.Write(testContent.data(), testContent.length());
bootstrapFile.Close();
EXPECT_FALSE(AzFramework::ProjectManager::HasBootstrapProjectName(m_projectPath.c_str()));
}
} // ProjectManagerTests
@@ -43,7 +43,6 @@ set(FILES
InterestManagerComponentTests.cpp
SQLiteConnectionTests.cpp
ProcessLaunchParseTests.cpp
ProjectManagerTests.cpp
Application.cpp
PlatformHelper.cpp
Scene.cpp