Integrating latest from github/staging
Integrating up through commit 5e1bdae
This commit is contained in:
@@ -1,655 +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.
|
||||
*
|
||||
*/
|
||||
#if defined(UNIT_TEST)
|
||||
|
||||
#include <AzCore/base.h>
|
||||
|
||||
#include "AssetCatalogUnitTests.h"
|
||||
|
||||
#include <AzCore/std/smart_ptr/shared_ptr.h>
|
||||
#include <AzCore/std/smart_ptr/make_shared.h>
|
||||
#include <AzCore/Casting/lossy_cast.h>
|
||||
#include <AzCore/IO/FileIO.h>
|
||||
#include <AzFramework/IO/LocalFileIO.h>
|
||||
#include <AzFramework/StringFunc/StringFunc.h>
|
||||
#include <AzFramework/Asset/AssetProcessorMessages.h>
|
||||
|
||||
#include <AzToolsFramework/Asset/AssetProcessorMessages.h>
|
||||
#include <native/AssetManager/assetProcessorManager.h>
|
||||
#include <native/utilities/PlatformConfiguration.h>
|
||||
#include <native/utilities/AssetBuilderInfo.h>
|
||||
#include <native/AssetManager/assetScanFolderInfo.h>
|
||||
#include <native/utilities/assetUtils.h>
|
||||
#include <native/resourcecompiler/RCBuilder.h>
|
||||
#include <native/assetprocessor.h>
|
||||
|
||||
#include <QTemporaryDir>
|
||||
#include <QString>
|
||||
#include <QCoreApplication>
|
||||
#include <QSet>
|
||||
#include <QList>
|
||||
#include <QTime>
|
||||
#include <QThread>
|
||||
#include <QPair>
|
||||
#include <AzToolsFramework/API/AssetDatabaseBus.h>
|
||||
#include <AzToolsFramework/API/EditorAssetSystemAPI.h>
|
||||
|
||||
namespace AssetProcessor
|
||||
{
|
||||
using namespace UnitTestUtils;
|
||||
using namespace AzFramework::AssetSystem;
|
||||
using namespace AzToolsFramework::AssetSystem;
|
||||
using namespace AzToolsFramework::AssetDatabase;
|
||||
|
||||
REGISTER_UNIT_TEST(AssetCatalogUnitTests)
|
||||
REGISTER_UNIT_TEST(AssetCatalogUnitTests_AssetInfo)
|
||||
|
||||
namespace
|
||||
{
|
||||
|
||||
// a utility class to redirect the location the database is stored to a different location so that we don't
|
||||
// touch real data during unit tests.
|
||||
class FakeDatabaseLocationListener
|
||||
: protected AzToolsFramework::AssetDatabase::AssetDatabaseRequests::Bus::Handler
|
||||
{
|
||||
public:
|
||||
FakeDatabaseLocationListener(const char* desiredLocation, const char* assetPath)
|
||||
: m_location(desiredLocation)
|
||||
, m_assetPath(assetPath)
|
||||
{
|
||||
AzToolsFramework::AssetDatabase::AssetDatabaseRequests::Bus::Handler::BusConnect();
|
||||
}
|
||||
~FakeDatabaseLocationListener()
|
||||
{
|
||||
AzToolsFramework::AssetDatabase::AssetDatabaseRequests::Bus::Handler::BusDisconnect();
|
||||
}
|
||||
protected:
|
||||
// IMPLEMENTATION OF -------------- AzToolsFramework::AssetDatabase::AssetDatabaseRequests::Bus::Listener
|
||||
bool GetAssetDatabaseLocation(AZStd::string& location) override
|
||||
{
|
||||
location = m_location;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ------------------------------------------------------------
|
||||
|
||||
private:
|
||||
AZStd::string m_location;
|
||||
AZStd::string m_assetPath;
|
||||
};
|
||||
|
||||
// Adds a scan folder to the config and to the database
|
||||
void AddScanFolder(const ScanFolderInfo& scanFolderInfo, PlatformConfiguration& config, AssetDatabaseConnection* dbConn)
|
||||
{
|
||||
config.AddScanFolder(scanFolderInfo);
|
||||
ScanFolderDatabaseEntry newScanFolder(
|
||||
scanFolderInfo.ScanPath().toStdString().c_str(),
|
||||
scanFolderInfo.GetDisplayName().toStdString().c_str(),
|
||||
scanFolderInfo.GetPortableKey().toStdString().c_str(),
|
||||
scanFolderInfo.GetOutputPrefix().toStdString().c_str(),
|
||||
scanFolderInfo.IsRoot());
|
||||
dbConn->SetScanFolder(newScanFolder);
|
||||
}
|
||||
|
||||
void BuildConfig(const QDir& tempPath, AssetDatabaseConnection* dbConn, PlatformConfiguration& config)
|
||||
{
|
||||
config.EnablePlatform({ "pc" ,{ "desktop", "renderer" } }, true);
|
||||
config.EnablePlatform({ "es3" ,{ "mobile", "renderer" } }, true);
|
||||
config.EnablePlatform({ "fandango" ,{ "console", "renderer" } }, false);
|
||||
AZStd::vector<AssetBuilderSDK::PlatformInfo> platforms;
|
||||
config.PopulatePlatformsForScanFolder(platforms);
|
||||
// PATH DisplayName PortKey outputfolder root recurse platforms order
|
||||
AddScanFolder(ScanFolderInfo(tempPath.filePath("subfolder4"), "subfolder4", "subfolder4", "", false, false, platforms, -6), config, dbConn); // subfolder 4 overrides subfolder3
|
||||
AddScanFolder(ScanFolderInfo(tempPath.filePath("subfolder3"), "subfolder3", "subfolder3", "", false, false, platforms, -5), config, dbConn); // subfolder 3 overrides subfolder2
|
||||
AddScanFolder(ScanFolderInfo(tempPath.filePath("subfolder2"), "subfolder2", "subfolder2", "", false, true, platforms, -2), config, dbConn); // subfolder 2 overrides subfolder1
|
||||
AddScanFolder(ScanFolderInfo(tempPath.filePath("subfolder1"), "subfolder1", "subfolder1", "editor", false, true, platforms, -1), config, dbConn); // subfolder1 overrides root
|
||||
AddScanFolder(ScanFolderInfo(tempPath.absolutePath(), "temp", "tempfolder", "", true, false, platforms, 0), config, dbConn); // add the root
|
||||
|
||||
config.AddMetaDataType("exportsettings", QString());
|
||||
|
||||
AZ::Uuid buildIDRcLegacy;
|
||||
BUILDER_ID_RC.GetUuid(buildIDRcLegacy);
|
||||
|
||||
AssetRecognizer rec;
|
||||
AssetPlatformSpec specpc;
|
||||
AssetPlatformSpec speces3;
|
||||
|
||||
speces3.m_extraRCParams = "somerandomparam";
|
||||
rec.m_name = "random files";
|
||||
rec.m_patternMatcher = AssetBuilderSDK::FilePatternMatcher("*.random", AssetBuilderSDK::AssetBuilderPattern::Wildcard);
|
||||
rec.m_platformSpecs.insert("pc", specpc);
|
||||
config.AddRecognizer(rec);
|
||||
|
||||
specpc.m_extraRCParams = ""; // blank must work
|
||||
speces3.m_extraRCParams = "testextraparams";
|
||||
|
||||
const char* builderTxt1Name = "txt files";
|
||||
rec.m_name = builderTxt1Name;
|
||||
rec.m_patternMatcher = AssetBuilderSDK::FilePatternMatcher("*.txt", AssetBuilderSDK::AssetBuilderPattern::Wildcard);
|
||||
rec.m_platformSpecs.insert("pc", specpc);
|
||||
rec.m_platformSpecs.insert("es3", speces3);
|
||||
|
||||
config.AddRecognizer(rec);
|
||||
|
||||
// Ignore recognizer
|
||||
AssetPlatformSpec ignore_spec;
|
||||
ignore_spec.m_extraRCParams = "skip";
|
||||
AssetRecognizer ignore_rec;
|
||||
ignore_rec.m_name = "ignore files";
|
||||
ignore_rec.m_patternMatcher = AssetBuilderSDK::FilePatternMatcher("*.ignore", AssetBuilderSDK::AssetBuilderPattern::Wildcard);
|
||||
ignore_rec.m_platformSpecs.insert("pc", specpc);
|
||||
ignore_rec.m_platformSpecs.insert("es3", ignore_spec);
|
||||
config.AddRecognizer(ignore_rec);
|
||||
|
||||
ExcludeAssetRecognizer excludeRecogniser;
|
||||
excludeRecogniser.m_name = "backup";
|
||||
excludeRecogniser.m_patternMatcher = AssetBuilderSDK::FilePatternMatcher(".*\\/savebackup\\/.*", AssetBuilderSDK::AssetBuilderPattern::Regex);
|
||||
config.AddExcludeRecognizer(excludeRecogniser);
|
||||
}
|
||||
|
||||
// Adds a source file and job entry to the database, jobId is output
|
||||
bool AddSourceAndJob(const char* scanFolder, const char* sourceRelPath, AssetDatabaseConnection* dbConn, AZ::s64& jobId, AZ::Uuid assetId = AZ::Uuid::CreateRandom())
|
||||
{
|
||||
ScanFolderDatabaseEntry scanFolderEntry;
|
||||
bool result = dbConn->GetScanFolderByPortableKey(scanFolder, scanFolderEntry);
|
||||
|
||||
if(!result)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
SourceDatabaseEntry sourceEntry(scanFolderEntry.m_scanFolderID, sourceRelPath, assetId, "fingerprint");
|
||||
dbConn->SetSource(sourceEntry);
|
||||
|
||||
JobDatabaseEntry jobEntry(sourceEntry.m_sourceID, "test", 1234, "pc", assetId, AzToolsFramework::AssetSystem::JobStatus::Completed, 12345);
|
||||
dbConn->SetJob(jobEntry);
|
||||
|
||||
jobId = jobEntry.m_jobID;
|
||||
return true;
|
||||
};
|
||||
|
||||
// Calls the GetRelativeProductPathFromFullSourceOrProductPath function and checks the return results, returning true if it matches both of the expected results
|
||||
bool TestGetRelativeProductPath(const QString fileToCheck, bool expectedToFind, AZStd::initializer_list<const char*> expectedPaths)
|
||||
{
|
||||
bool relPathfound = false;
|
||||
AZStd::string relPath;
|
||||
AZStd::string fullPath(fileToCheck.toStdString().c_str());
|
||||
|
||||
EBUS_EVENT_RESULT(relPathfound, AzToolsFramework::AssetSystemRequestBus, GetRelativeProductPathFromFullSourceOrProductPath, fullPath, relPath);
|
||||
|
||||
if (relPathfound != expectedToFind)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto& path : expectedPaths)
|
||||
{
|
||||
if (relPath == path)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
// Calls the GetFullSourcePathFromRelativeProductPath function and checks the return results, returning true if it matches both of the expected results
|
||||
bool TestGetFullSourcePath(const QString& fileToCheck, const QDir& tempPath, bool expectToFind, const char* expectedPath)
|
||||
{
|
||||
bool fullPathfound = false;
|
||||
AZStd::string fullPath;
|
||||
AZStd::string relPath(fileToCheck.toStdString().c_str());
|
||||
|
||||
EBUS_EVENT_RESULT(fullPathfound, AzToolsFramework::AssetSystemRequestBus, GetFullSourcePathFromRelativeProductPath, relPath, fullPath);
|
||||
|
||||
if (fullPathfound != expectToFind)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
QString output(fullPath.c_str());
|
||||
output.remove(0, tempPath.path().length() + 1); //adding one for the native separator
|
||||
|
||||
return (output == expectedPath);
|
||||
}
|
||||
|
||||
} // end anon namespace
|
||||
|
||||
void AssetCatalogUnitTests::StartTest()
|
||||
{
|
||||
QDir oldRoot;
|
||||
AssetUtilities::ComputeAssetRoot(oldRoot);
|
||||
AssetUtilities::ResetAssetRoot();
|
||||
|
||||
// the canonicalization of the path here is to get around the fact that on some platforms
|
||||
// the "temporary" folder location could be junctioned into some other folder and getting "QDir::current()"
|
||||
// and other similar functions may actually return a different string but still be referring to the same folder
|
||||
QTemporaryDir dir;
|
||||
QDir tempPath(dir.path());
|
||||
QString canonicalTempDirPath = AssetUtilities::NormalizeDirectoryPath(tempPath.canonicalPath());
|
||||
UnitTestUtils::ScopedDir changeDir(canonicalTempDirPath);
|
||||
tempPath = QDir(canonicalTempDirPath);
|
||||
NetworkRequestID requestId(1, 1);
|
||||
|
||||
FakeDatabaseLocationListener listener(tempPath.filePath("statedatabase.sqlite").toUtf8().constData(), "displayString");
|
||||
|
||||
AZStd::unique_ptr<AssetDatabaseConnection> dbConn = AZStd::make_unique<AssetDatabaseConnection>();
|
||||
dbConn->OpenDatabase();
|
||||
|
||||
CreateDummyFile(tempPath.absoluteFilePath("bootstrap.cfg"), QString("sys_game_folder=SamplesProject\n"));
|
||||
|
||||
// system is already actually initialized, along with gEnv, so this will always return that game name.
|
||||
QString gameName = AssetUtilities::ComputeGameName();
|
||||
|
||||
// update the engine root
|
||||
AssetUtilities::ResetAssetRoot();
|
||||
QDir newRoot;
|
||||
AssetUtilities::ComputeAssetRoot(newRoot, &tempPath);
|
||||
|
||||
UNIT_TEST_EXPECT_FALSE(gameName.isEmpty());
|
||||
// should create cache folder in the root, and read everything from there.
|
||||
|
||||
QSet<QString> expectedFiles;
|
||||
// set up some interesting files:
|
||||
expectedFiles << tempPath.absoluteFilePath("rootfile2.txt");
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder1/rootfile1.txt"); // note: Must override the actual root file
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder1/basefile.txt");
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder2/basefile.txt");
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder2/aaa/basefile.txt");
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder2/aaa/bbb/basefile.txt");
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder2/aaa/bbb/ccc/basefile.txt");
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder2/aaa/bbb/ccc/ddd/basefile.txt");
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder3/BaseFile.txt"); // note the case upper here
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder8/a/b/c/test.txt");
|
||||
|
||||
// subfolder3 is not recursive so none of these should show up in any scan or override check
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder3/aaa/basefile.txt");
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder3/aaa/bbb/basefile.txt");
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder3/aaa/bbb/ccc/basefile.txt");
|
||||
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder3/uniquefile.txt"); // only exists in subfolder3
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder3/uniquefile.ignore"); // only exists in subfolder3
|
||||
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder3/rootfile3.txt"); // must override rootfile3 in root
|
||||
expectedFiles << tempPath.absoluteFilePath("rootfile1.txt");
|
||||
expectedFiles << tempPath.absoluteFilePath("rootfile3.txt");
|
||||
expectedFiles << tempPath.absoluteFilePath("unrecognised.file"); // a file that should not be recognised
|
||||
expectedFiles << tempPath.absoluteFilePath("unrecognised2.file"); // a file that should not be recognised
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder1/test/test.format"); // a file that should be recognised
|
||||
expectedFiles << tempPath.absoluteFilePath("test.format"); // a file that should NOT be recognised
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder3/somefile.xxx");
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder3/savebackup/test.txt");//file that should be excluded
|
||||
expectedFiles << tempPath.absoluteFilePath("subfolder3/somerandomfile.random");
|
||||
|
||||
for (const QString& expect : expectedFiles)
|
||||
{
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(expect));
|
||||
AZ_TracePrintf(AssetProcessor::DebugChannel, "Created file %s with msecs %llu\n", expect.toUtf8().constData(),
|
||||
QFileInfo(expect).lastModified().toMSecsSinceEpoch());
|
||||
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
QThread::msleep(35); // give at least some milliseconds so that the files never share the same timestamp exactly
|
||||
#else
|
||||
// on platforms such as mac, the file time resolution is only a second :(
|
||||
QThread::msleep(1001);
|
||||
#endif
|
||||
}
|
||||
|
||||
PlatformConfiguration config;
|
||||
BuildConfig(tempPath, dbConn.get(), config);
|
||||
|
||||
AssetCatalog assetCatalog(nullptr, &config);
|
||||
QDir cacheRoot;
|
||||
UNIT_TEST_EXPECT_TRUE(AssetUtilities::ComputeProjectCacheRoot(cacheRoot));
|
||||
QString normalizedCacheRoot = AssetUtilities::NormalizeDirectoryPath(cacheRoot.absolutePath());
|
||||
|
||||
// make sure it picked up the one in the current folder
|
||||
|
||||
QString normalizedDirPathCheck = AssetUtilities::NormalizeDirectoryPath(tempPath.absoluteFilePath("Cache/" + gameName));
|
||||
UNIT_TEST_EXPECT_TRUE(normalizedCacheRoot == normalizedDirPathCheck);
|
||||
QDir normalizedCacheRootDir(normalizedCacheRoot);
|
||||
|
||||
// ----- Test the get asset path functions, which given a full path to an asset, checks the mappings and turns it into an Asset ID ---
|
||||
{
|
||||
// sanity check - make sure it does not crash or misbehave when given empty names
|
||||
QString fileToCheck = "";
|
||||
{
|
||||
UnitTestUtils::AssertAbsorber absorb;
|
||||
// empty requests should generate an assert.
|
||||
GetRelativeProductPathFromFullSourceOrProductPathRequest request(fileToCheck.toUtf8().constData());
|
||||
UNIT_TEST_EXPECT_TRUE(absorb.m_numAssertsAbsorbed == 1);
|
||||
GetFullSourcePathFromRelativeProductPathRequest sourceRequest(fileToCheck.toUtf8().constData());
|
||||
UNIT_TEST_EXPECT_TRUE(absorb.m_numAssertsAbsorbed == 2);
|
||||
}
|
||||
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetRelativeProductPath("", false, {""}));
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetFullSourcePath("", tempPath, false, ""));
|
||||
|
||||
// Add a source file with 4 products
|
||||
{
|
||||
AZ::s64 jobId;
|
||||
bool result = AddSourceAndJob("subfolder3", "BaseFile.txt", dbConn.get(), jobId);
|
||||
UNIT_TEST_EXPECT_TRUE(result);
|
||||
|
||||
AZ::u32 productSubId = 0;
|
||||
for (auto& relativeProductPath : { "subfolder3/basefilez.arc2", "subfolder3/basefileaz.azm2", "subfolder3/basefile.arc2", "subfolder3/basefile.azm2" })
|
||||
{
|
||||
ProductDatabaseEntry newProduct(jobId, productSubId++, cacheRoot.relativeFilePath(relativeProductPath).toStdString().c_str(), AZ::Data::AssetType::CreateRandom());
|
||||
dbConn->SetProduct(newProduct);
|
||||
}
|
||||
}
|
||||
|
||||
// GetRelativeProductPathFromFullSourceOrProductPath has 4 code paths:
|
||||
// 1) Relative input paths are returned straight away
|
||||
// 2) Paths inside the cache folder are transformed to product paths, no database involvement
|
||||
// 3) Source files that have a product return the product path
|
||||
// 4) Source files that don't have a product return the source file's relative path since that is the path a product might have
|
||||
|
||||
// Failure case
|
||||
#if defined(AZ_PLATFORM_WINDOWS)
|
||||
fileToCheck = "d:\\test.txt";
|
||||
#else
|
||||
fileToCheck = "/test.txt"; // rooted
|
||||
#endif
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetRelativeProductPath(fileToCheck, false, { fileToCheck.toStdString().c_str() }));
|
||||
|
||||
// (Case 1) feed it a relative path
|
||||
fileToCheck = "\test.txt";
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetRelativeProductPath(fileToCheck, true, { "\test.txt" }));
|
||||
|
||||
// (Case 2) feed it a product path with gamename
|
||||
fileToCheck = normalizedCacheRootDir.filePath("pc/" + gameName + "/aaa/basefile.txt");
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetRelativeProductPath(fileToCheck, true, { "aaa/basefile.txt" }));
|
||||
|
||||
// (Case 2) feed it a product path without gamename
|
||||
fileToCheck = normalizedCacheRootDir.filePath("pc/basefile.txt");
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetRelativeProductPath(fileToCheck, true, { "basefile.txt" }));
|
||||
|
||||
// (Case 2) feed it a product path with gamename but poor casing (test 1: the pc platform is not matching case)
|
||||
fileToCheck = normalizedCacheRootDir.filePath("Pc/" + gameName + "/aaa/basefile.txt");
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetRelativeProductPath(fileToCheck, true, { "aaa/basefile.txt" }));
|
||||
|
||||
// (Case 2) feed it a product path with gamename but poor casing (test 2: the gameName is not matching case)
|
||||
fileToCheck = normalizedCacheRootDir.filePath("pc/" + gameName.toUpper() + "/aaa/basefile.txt");
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetRelativeProductPath(fileToCheck, true, { "aaa/basefile.txt" }));
|
||||
|
||||
// (Case 2) feed it a product path that resolves to a directory name instead of a file.
|
||||
fileToCheck = normalizedCacheRootDir.filePath("pc/" + gameName.toUpper() + "/aaa");
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetRelativeProductPath(fileToCheck, true, { "aaa" }));
|
||||
|
||||
// Case 3
|
||||
fileToCheck = tempPath.absoluteFilePath("subfolder3/BaseFile.txt");
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetRelativeProductPath(fileToCheck, true, { "basefilez.arc2", "basefileaz.azm2", "basefile.arc2", "basefile.azm2" }));
|
||||
|
||||
// Case 4
|
||||
fileToCheck = tempPath.absoluteFilePath("subfolder2/aaa/basefile.txt");
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetRelativeProductPath(fileToCheck, true, { "aaa/basefile.txt" }));
|
||||
|
||||
// ----- Test the ProcessGetFullAssetPath function
|
||||
{
|
||||
QStringList pcouts;
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/subfolder3/randomfileoutput.random"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/subfolder3/randomfileoutput.random1"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/subfolder3/randomfileoutput.random2"));
|
||||
|
||||
AZ::s64 jobId;
|
||||
bool result = AddSourceAndJob("subfolder3", "somerandomfile.random", dbConn.get(), jobId);
|
||||
UNIT_TEST_EXPECT_TRUE(result);
|
||||
|
||||
AZ::u32 productSubID = 0;
|
||||
for (auto& product : pcouts)
|
||||
{
|
||||
ProductDatabaseEntry newProduct(jobId, productSubID++, cacheRoot.relativeFilePath(product).toStdString().c_str(), AZ::Data::AssetType::CreateRandom());
|
||||
dbConn->SetProduct(newProduct);
|
||||
}
|
||||
}
|
||||
|
||||
//feed it an relative product, and expect a full, absolute source file path in return.
|
||||
fileToCheck = "subfolder3/randomfileoutput.random1";
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetFullSourcePath(fileToCheck, tempPath, true, "subfolder3/somerandomfile.random"));
|
||||
|
||||
//feed it another relative product
|
||||
fileToCheck = "subfolder3/randomfileoutput.random2";
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetFullSourcePath(fileToCheck, tempPath, true, "subfolder3/somerandomfile.random"));
|
||||
|
||||
//feed it the same relative product with different separators
|
||||
fileToCheck = "subfolder3\\randomfileoutput.random2";
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetFullSourcePath(fileToCheck, tempPath, true, "subfolder3/somerandomfile.random"));
|
||||
|
||||
//feed it a full path
|
||||
fileToCheck = tempPath.filePath("somefolder/somefile.txt");
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetFullSourcePath(fileToCheck, tempPath, true, "somefolder/somefile.txt"));
|
||||
|
||||
//feed it a path with alias and asset id
|
||||
fileToCheck = "@assets@/subfolder3/randomfileoutput.random1";
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetFullSourcePath(fileToCheck, tempPath, true, "subfolder3/somerandomfile.random"));
|
||||
|
||||
//feed it a path with some random alias and asset id
|
||||
fileToCheck = "@somerandomalias@/subfolder3/randomfileoutput.random1";
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetFullSourcePath(fileToCheck, tempPath, true, "subfolder3/somerandomfile.random"));
|
||||
|
||||
//feed it a path with some random alias and asset id but no separator
|
||||
fileToCheck = "@somerandomalias@subfolder3/randomfileoutput.random1";
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetFullSourcePath(fileToCheck, tempPath, true, "subfolder3/somerandomfile.random"));
|
||||
|
||||
//feed it a path with alias and input name
|
||||
fileToCheck = "@assets@/somerandomfile.random";
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetFullSourcePath(fileToCheck, tempPath, true, "subfolder3/somerandomfile.random"));
|
||||
|
||||
//feed it an absolute path with cacheroot
|
||||
fileToCheck = normalizedCacheRootDir.filePath("pc/" + gameName + "/subfolder3/randomfileoutput.random1");
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetFullSourcePath(fileToCheck, tempPath, true, "subfolder3/somerandomfile.random"));
|
||||
|
||||
//feed it a productName directly
|
||||
fileToCheck = "pc/" + gameName + "/subfolder3/randomfileoutput.random1";
|
||||
UNIT_TEST_EXPECT_TRUE(TestGetFullSourcePath(fileToCheck, tempPath, true, "subfolder3/somerandomfile.random"));
|
||||
}
|
||||
|
||||
Q_EMIT UnitTestPassed();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void AssetCatalogUnitTests_AssetInfo::StartTest()
|
||||
{
|
||||
using namespace AZ::Data;
|
||||
using namespace AzToolsFramework;
|
||||
|
||||
// the canonicalization of the path here is to get around the fact that on some platforms
|
||||
// the "temporary" folder location could be junctioned into some other folder and getting "QDir::current()"
|
||||
// and other similar functions may actually return a different string but still be referring to the same folder
|
||||
QTemporaryDir dir;
|
||||
QDir tempPath(dir.path());
|
||||
QString canonicalTempDirPath = AssetUtilities::NormalizeDirectoryPath(tempPath.canonicalPath());
|
||||
UnitTestUtils::ScopedDir changeDir(canonicalTempDirPath);
|
||||
tempPath = QDir(canonicalTempDirPath);
|
||||
|
||||
CreateDummyFile(tempPath.absoluteFilePath("bootstrap.cfg"), QString("sys_game_folder=SamplesProject\n"));
|
||||
|
||||
// system is already actually initialized, along with gEnv, so this will always return that game name.
|
||||
QString gameName = AssetUtilities::ComputeGameName();
|
||||
|
||||
// update the engine root
|
||||
AssetUtilities::ResetAssetRoot();
|
||||
QDir newRoot;
|
||||
AssetUtilities::ComputeAssetRoot(newRoot, &tempPath);
|
||||
QDir cacheRoot;
|
||||
AssetUtilities::ComputeProjectCacheRoot(cacheRoot);
|
||||
AZStd::string cacheRootPath = cacheRoot.absolutePath().toStdString().c_str();
|
||||
|
||||
FakeDatabaseLocationListener listener(tempPath.filePath("statedatabase.sqlite").toUtf8().constData(), "displayString");
|
||||
|
||||
AZStd::unique_ptr<AssetDatabaseConnection> dbConn = AZStd::make_unique<AssetDatabaseConnection>();
|
||||
dbConn->OpenDatabase();
|
||||
|
||||
PlatformConfiguration config;
|
||||
BuildConfig(tempPath, dbConn.get(), config);
|
||||
|
||||
AssetCatalog assetCatalog(nullptr, &config);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
AssetId assetA(AZ::Uuid::CreateRandom(), 0);
|
||||
AZ::Uuid assetALegacyUuid = AZ::Uuid::CreateRandom();
|
||||
AssetType assetAType = AssetType::CreateRandom();
|
||||
AZStd::string assetAFileFilter = "*.source";
|
||||
AZStd::string subfolder1AbsolutePath = tempPath.absoluteFilePath("subfolder1").toStdString().c_str();
|
||||
AZStd::string assetASourceRelPath = "assetA.source";
|
||||
AZStd::string assetASourceDatabasePath = "editor/assetA.source";
|
||||
AZStd::string assetAProductRelPath = "editor/assetA.product";
|
||||
|
||||
AZStd::string assetAFullPath;
|
||||
AzFramework::StringFunc::Path::Join(subfolder1AbsolutePath.c_str(), assetASourceRelPath.c_str(), assetAFullPath);
|
||||
CreateDummyFile(QString::fromUtf8(assetAFullPath.c_str()), "Its the Asset A"); // 15 bytes of data
|
||||
|
||||
AZStd::string assetAProductFullPath;
|
||||
AzFramework::StringFunc::Path::Join(cacheRootPath.c_str(), assetAProductRelPath.c_str(), assetAProductFullPath);
|
||||
CreateDummyFile(QString::fromUtf8(assetAProductFullPath.c_str()), "Its a product A"); // 15 bytes of data
|
||||
|
||||
auto getAssetInfoById = [assetA, assetAType, subfolder1AbsolutePath](bool expectedResult, AZStd::string expectedRelPath, AZStd::string expectedRootPath, AssetType assetType) -> bool
|
||||
{
|
||||
bool result = false;
|
||||
AssetInfo assetInfo;
|
||||
AZStd::string rootPath;
|
||||
AssetSystemRequestBus::BroadcastResult(result, &AssetSystem::AssetSystemRequest::GetAssetInfoById, assetA, assetType, assetInfo, rootPath);
|
||||
|
||||
if (result != expectedResult)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (expectedResult)
|
||||
{
|
||||
return (assetInfo.m_assetId == assetA)
|
||||
&& (assetInfo.m_assetType == assetAType)
|
||||
&& (assetInfo.m_relativePath == expectedRelPath)
|
||||
&& (assetInfo.m_sizeBytes == 15)
|
||||
&& (rootPath == expectedRootPath);
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
auto getAssetInfoByIdPair = [&](bool expectedResult, AZStd::string expectedRelPath, AZStd::string expectedRootPath) -> bool
|
||||
{
|
||||
// First test without providing the assetType
|
||||
bool result = getAssetInfoById(expectedResult, expectedRelPath, expectedRootPath, AssetType::CreateNull());
|
||||
|
||||
// If successful, test again, this time providing the assetType
|
||||
if (result)
|
||||
{
|
||||
result = getAssetInfoById(expectedResult, expectedRelPath, expectedRootPath, assetAType);
|
||||
}
|
||||
|
||||
return result;
|
||||
};
|
||||
|
||||
auto getSourceInfoBySourcePath = [](bool expectedResult, AZStd::string sourcePath, AZ::Uuid expectedUuid, AZStd::string expectedRelPath, AZStd::string expectedRootPath, AZ::Data::AssetType expectedType = AZ::Data::s_invalidAssetType) -> bool
|
||||
{
|
||||
bool result = false;
|
||||
AssetInfo assetInfo;
|
||||
AZStd::string rootPath;
|
||||
AssetSystemRequestBus::BroadcastResult(result, &AssetSystem::AssetSystemRequest::GetSourceInfoBySourcePath, sourcePath.c_str(), assetInfo, rootPath);
|
||||
|
||||
if (result != expectedResult)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (expectedResult)
|
||||
{
|
||||
return (assetInfo.m_assetId == expectedUuid)
|
||||
&& (assetInfo.m_assetType == expectedType)
|
||||
&& (assetInfo.m_relativePath == expectedRelPath)
|
||||
&& (assetInfo.m_sizeBytes == 15)
|
||||
&& (rootPath == expectedRootPath)
|
||||
;
|
||||
}
|
||||
|
||||
return true;
|
||||
};
|
||||
|
||||
//Test 1: Asset not in database
|
||||
UNIT_TEST_EXPECT_TRUE(getAssetInfoByIdPair(false, "", ""));
|
||||
UNIT_TEST_EXPECT_TRUE(getSourceInfoBySourcePath(false, "", AZ::Uuid::CreateNull(), "", ""));
|
||||
|
||||
// Add asset to database
|
||||
AZ::s64 jobId;
|
||||
UNIT_TEST_EXPECT_TRUE(AddSourceAndJob("subfolder1", assetASourceDatabasePath.c_str(), dbConn.get(), jobId, assetA.m_guid));
|
||||
ProductDatabaseEntry newProductEntry(jobId, 0, assetAProductRelPath.c_str(), assetAType);
|
||||
dbConn->SetProduct(newProductEntry);
|
||||
|
||||
// Test 2: Asset in database, not registered as source asset
|
||||
// note that when asking for products, a performance improvement causes the catalog to use its REGISTRY
|
||||
// rather than the database to ask for products, so to set this up the registry must be present and must have the asset registered within it
|
||||
AzFramework::AssetSystem::AssetNotificationMessage message(assetAProductRelPath.c_str(), AssetNotificationMessage::AssetChanged, assetAType);
|
||||
message.m_sizeBytes = 15;
|
||||
message.m_assetId = AZ::Data::AssetId(assetA.m_guid, 0);
|
||||
assetCatalog.OnAssetMessage("pc", message);
|
||||
|
||||
// also of note: When looking up products, you don't get a root path since they are all in the cache.
|
||||
// its important here that we specifically get an empty root path.
|
||||
UNIT_TEST_EXPECT_TRUE(getAssetInfoByIdPair(true, assetAProductRelPath, ""));
|
||||
|
||||
// this call has to work with full and relative path.
|
||||
UNIT_TEST_EXPECT_TRUE(getSourceInfoBySourcePath(true, assetASourceRelPath.c_str(), assetA.m_guid, assetASourceRelPath.c_str(), subfolder1AbsolutePath.c_str()));
|
||||
UNIT_TEST_EXPECT_TRUE(getSourceInfoBySourcePath(true, assetAFullPath.c_str(), assetA.m_guid, assetASourceRelPath.c_str(), subfolder1AbsolutePath.c_str()));
|
||||
|
||||
dbConn->RemoveProductsByJobID(jobId);
|
||||
|
||||
// similar to the above, because its not the DB that is used for products, we have to inform the catalog that its gone
|
||||
message.m_type = AssetNotificationMessage::AssetRemoved;
|
||||
assetCatalog.OnAssetMessage("pc", message);
|
||||
|
||||
// Add to queue
|
||||
assetCatalog.OnSourceQueued(assetA.m_guid, assetALegacyUuid, subfolder1AbsolutePath.c_str(), assetASourceRelPath.c_str());
|
||||
|
||||
//Test 3: Asset in queue, not registered as source asset
|
||||
UNIT_TEST_EXPECT_TRUE(getAssetInfoByIdPair(false, "", ""));
|
||||
|
||||
// this call should STILL work even after the above call to "OnSourceQueued" since its explicitly asking for the source details.
|
||||
UNIT_TEST_EXPECT_TRUE(getSourceInfoBySourcePath(true, assetASourceRelPath.c_str(), assetA.m_guid, assetASourceRelPath.c_str(), subfolder1AbsolutePath.c_str()));
|
||||
UNIT_TEST_EXPECT_TRUE(getSourceInfoBySourcePath(true, assetAFullPath.c_str(), assetA.m_guid, assetASourceRelPath.c_str(), subfolder1AbsolutePath.c_str()));
|
||||
|
||||
// Register as source type
|
||||
// note that once this call has been made, ALL REQUESTS for this type of asset should always include an appropriate type (non zero)
|
||||
ToolsAssetSystemBus::Broadcast(&ToolsAssetSystemRequests::RegisterSourceAssetType, assetAType, assetAFileFilter.c_str());
|
||||
|
||||
//Test 4: Asset in queue, registered as source asset
|
||||
UNIT_TEST_EXPECT_TRUE(getAssetInfoByIdPair(true, assetASourceRelPath, subfolder1AbsolutePath));
|
||||
|
||||
// these calls are identical to the two above, but should continue to work even though we have registered the asset type as a source asset type.
|
||||
UNIT_TEST_EXPECT_TRUE(getSourceInfoBySourcePath(true, assetASourceRelPath.c_str(), assetA.m_guid, assetASourceRelPath.c_str(), subfolder1AbsolutePath.c_str(), assetAType));
|
||||
UNIT_TEST_EXPECT_TRUE(getSourceInfoBySourcePath(true, assetAFullPath.c_str(), assetA.m_guid, assetASourceRelPath.c_str(), subfolder1AbsolutePath.c_str(), assetAType));
|
||||
|
||||
// Remove from queue
|
||||
assetCatalog.OnSourceFinished(assetA.m_guid, assetALegacyUuid);
|
||||
|
||||
// Add asset to database
|
||||
ProductDatabaseEntry assetAEntry(jobId, 0, assetAProductRelPath.c_str(), assetAType);
|
||||
dbConn->SetProduct(assetAEntry);
|
||||
|
||||
//Test 5: Asset in database, registered as source asset
|
||||
UNIT_TEST_EXPECT_TRUE(getAssetInfoByIdPair(true, assetASourceRelPath, subfolder1AbsolutePath));
|
||||
|
||||
// at this point the details about the asset in question is no longer in memory, only the database. However, these calls should continue find the
|
||||
// information, because the system is supposed check both the database AND the in-memory queue in the to find the info being requested.
|
||||
UNIT_TEST_EXPECT_TRUE(getSourceInfoBySourcePath(true, assetASourceRelPath.c_str(), assetA.m_guid, assetASourceRelPath.c_str(), subfolder1AbsolutePath.c_str(), assetAType));
|
||||
UNIT_TEST_EXPECT_TRUE(getSourceInfoBySourcePath(true, assetAFullPath.c_str(), assetA.m_guid, assetASourceRelPath.c_str(), subfolder1AbsolutePath.c_str(), assetAType));
|
||||
|
||||
Q_EMIT UnitTestPassed();
|
||||
}
|
||||
|
||||
#include <native/unittests/moc_AssetCatalogUnitTests.cpp>
|
||||
} // namespace AssetProcessor
|
||||
|
||||
#endif
|
||||
@@ -15,7 +15,7 @@
|
||||
#include "AssetProcessorManagerUnitTests.h"
|
||||
|
||||
#include <AzCore/Casting/lossy_cast.h>
|
||||
|
||||
#include <AzCore/Settings/SettingsRegistryMergeUtils.h>
|
||||
|
||||
#include "MockApplicationManager.h"
|
||||
#include "native/FileWatcher/FileWatcher.h"
|
||||
@@ -56,7 +56,7 @@ namespace AssetProcessor
|
||||
using GetFullSourcePathFromRelativeProductPathResponse = AzFramework::AssetSystem::GetFullSourcePathFromRelativeProductPathResponse;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
REGISTER_UNIT_TEST(AssetProcessorManagerUnitTests_ScanFolders)
|
||||
|
||||
@@ -138,7 +138,7 @@ namespace AssetProcessor
|
||||
AssetUtilities::ComputeAssetRoot(oldRoot);
|
||||
AssetUtilities::ResetAssetRoot();
|
||||
FileWatcher fileWatcher;
|
||||
|
||||
|
||||
UNIT_TEST_EXPECT_TRUE(QDir::temp().exists());
|
||||
QString tmpDirPath = AssetUtilities::NormalizeDirectoryPath(QDir::tempPath());
|
||||
|
||||
@@ -153,8 +153,7 @@ namespace AssetProcessor
|
||||
UnitTestUtils::ScopedDir changeDir(canonicalTempDirPath);
|
||||
NetworkRequestID requestId(1, 1);
|
||||
|
||||
// system is already actually initialized, along with gEnv, so this will always return that game name.
|
||||
QString gameName = AssetUtilities::ComputeGameName(AssetProcessorManagerTestGameProject);
|
||||
QString gameName = AssetUtilities::ComputeProjectName(AssetProcessorManagerTestGameProject);
|
||||
|
||||
// update the engine root
|
||||
AssetUtilities::ResetAssetRoot();
|
||||
@@ -162,6 +161,13 @@ namespace AssetProcessor
|
||||
AssetUtilities::ComputeAssetRoot(newRoot, &tempPath);
|
||||
|
||||
// create a dummy file in the cache folder, so the folder structure gets created
|
||||
// Override the cache folder to be the within the temporary directory
|
||||
auto projectCacheRootKey = AZ::SettingsRegistryInterface::FixedValueString::format("%s/project_cache_path", AZ::SettingsRegistryMergeUtils::BootstrapSettingsRootKey);
|
||||
if (auto settingsRegistry = AZ::SettingsRegistry::Get(); settingsRegistry != nullptr)
|
||||
{
|
||||
settingsRegistry->Set(projectCacheRootKey, tempPath.absoluteFilePath("Cache").toUtf8().data());
|
||||
AZ::SettingsRegistryMergeUtils::MergeSettingsToRegistry_AddRuntimeFilePaths(*settingsRegistry);
|
||||
}
|
||||
QDir projectCacheRoot;
|
||||
AssetUtilities::ComputeProjectCacheRoot(projectCacheRoot);
|
||||
CreateDummyFile(projectCacheRoot.absoluteFilePath("placeholder.txt"));
|
||||
@@ -343,7 +349,7 @@ namespace AssetProcessor
|
||||
|
||||
// make sure it picked up the one in the cache and not for example the real working folder
|
||||
|
||||
QString normalizedDirPathCheck = AssetUtilities::NormalizeDirectoryPath(QDir(canonicalTempDirPath).absoluteFilePath("Cache/" + gameName));
|
||||
QString normalizedDirPathCheck = AssetUtilities::NormalizeDirectoryPath(QDir(canonicalTempDirPath).absoluteFilePath("Cache"));
|
||||
UNIT_TEST_EXPECT_TRUE(normalizedCacheRoot == normalizedDirPathCheck);
|
||||
QDir normalizedCacheRootDir(normalizedCacheRoot);
|
||||
|
||||
@@ -441,7 +447,7 @@ namespace AssetProcessor
|
||||
QString relativePathFromWatchFolder = "uniquefile.txt";
|
||||
QString watchFolderPath = tempPath.absoluteFilePath("subfolder3");
|
||||
QString absolutePath = AssetUtilities::NormalizeFilePath(watchFolderPath + "/" + relativePathFromWatchFolder);
|
||||
|
||||
|
||||
QMetaObject::invokeMethod(&apm, "AssessModifiedFile", Qt::QueuedConnection, Q_ARG(QString, absolutePath));
|
||||
|
||||
UNIT_TEST_EXPECT_TRUE(BlockUntil(idling, 5000));
|
||||
@@ -469,7 +475,7 @@ namespace AssetProcessor
|
||||
UNIT_TEST_EXPECT_TRUE(processResults[checkIdx].m_jobEntry.m_watchFolderPath == AssetUtilities::NormalizeFilePath(watchFolderPath));
|
||||
UNIT_TEST_EXPECT_TRUE(processResults[checkIdx].m_jobEntry.m_pathRelativeToWatchFolder == "uniquefile.txt");
|
||||
UNIT_TEST_EXPECT_TRUE(processResults[checkIdx].m_jobEntry.m_databaseSourceName == "uniquefile.txt");
|
||||
QString platformFolder = cacheRoot.filePath(QString::fromUtf8(processResults[checkIdx].m_jobEntry.m_platformInfo.m_identifier.c_str()) + "/" + gameName.toLower());
|
||||
QString platformFolder = cacheRoot.filePath(QString::fromUtf8(processResults[checkIdx].m_jobEntry.m_platformInfo.m_identifier.c_str()));
|
||||
platformFolder = AssetUtilities::NormalizeDirectoryPath(platformFolder);
|
||||
UNIT_TEST_EXPECT_TRUE(processResults[checkIdx].m_destinationPath.startsWith(platformFolder));
|
||||
UNIT_TEST_EXPECT_TRUE(processResults[checkIdx].m_jobEntry.m_computedFingerprint != 0);
|
||||
@@ -659,8 +665,8 @@ namespace AssetProcessor
|
||||
|
||||
|
||||
QStringList es3outs;
|
||||
es3outs.push_back(cacheRoot.filePath(QString("es3/") + gameName + "/basefile.arc1"));
|
||||
es3outs.push_back(cacheRoot.filePath(QString("es3/") + gameName + "/basefile.arc2"));
|
||||
es3outs.push_back(cacheRoot.filePath(QString("es3/basefile.arc1")));
|
||||
es3outs.push_back(cacheRoot.filePath(QString("es3/basefile.arc2")));
|
||||
|
||||
// feed it the messages its waiting for (create the files)
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(es3outs[0], "products."));
|
||||
@@ -790,7 +796,7 @@ namespace AssetProcessor
|
||||
assetMessages.clear();
|
||||
|
||||
es3outs.clear();
|
||||
es3outs.push_back(cacheRoot.filePath(QString("es3/") + gameName + "/basefile.azm"));
|
||||
es3outs.push_back(cacheRoot.filePath(QString("es3/basefile.azm")));
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(es3outs[0], "products."));
|
||||
|
||||
//Invoke Asset Processed for es3 platform , txt files2 job description
|
||||
@@ -815,7 +821,7 @@ namespace AssetProcessor
|
||||
assetMessages.clear();
|
||||
|
||||
QStringList pcouts;
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/basefile.arc1"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/basefile.arc1")));
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(pcouts[0], "products."));
|
||||
|
||||
response.m_outputProducts.clear();
|
||||
@@ -843,7 +849,7 @@ namespace AssetProcessor
|
||||
assetMessages.clear();
|
||||
|
||||
pcouts.clear();
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/basefile.azm"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/basefile.azm")));
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(pcouts[0], "products."));
|
||||
|
||||
response.m_outputProducts.clear();
|
||||
@@ -1012,7 +1018,7 @@ namespace AssetProcessor
|
||||
{
|
||||
QString processFile1 = processResults[checkIdx].m_jobEntry.GetAbsoluteSourcePath();
|
||||
UNIT_TEST_EXPECT_TRUE(AssetUtilities::NormalizeFilePath(processFile1) == AssetUtilities::NormalizeFilePath(absolutePath));
|
||||
QString platformFolder = cacheRoot.filePath(QString::fromUtf8(processResults[checkIdx].m_jobEntry.m_platformInfo.m_identifier.c_str()) + "/" + gameName.toLower());
|
||||
QString platformFolder = cacheRoot.filePath(QString::fromUtf8(processResults[checkIdx].m_jobEntry.m_platformInfo.m_identifier.c_str()));
|
||||
platformFolder = AssetUtilities::NormalizeDirectoryPath(platformFolder);
|
||||
processFile1 = processResults[checkIdx].m_destinationPath;
|
||||
UNIT_TEST_EXPECT_TRUE(processFile1.startsWith(platformFolder));
|
||||
@@ -1029,12 +1035,12 @@ namespace AssetProcessor
|
||||
QStringList pcouts2;
|
||||
es3outs.clear();
|
||||
pcouts.clear();
|
||||
es3outs.push_back(cacheRoot.filePath(QString("es3/") + gameName + "/basefilea.arc1"));
|
||||
es3outs2.push_back(cacheRoot.filePath(QString("es3/") + gameName + "/basefilea.azm"));
|
||||
es3outs.push_back(cacheRoot.filePath(QString("es3/basefilea.arc1")));
|
||||
es3outs2.push_back(cacheRoot.filePath(QString("es3/basefilea.azm")));
|
||||
// note that the ES3 outs have changed
|
||||
// but the pc outs are still the same.
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/basefile.arc1"));
|
||||
pcouts2.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/basefile.azm"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/basefile.arc1")));
|
||||
pcouts2.push_back(cacheRoot.filePath(QString("pc/basefile.azm")));
|
||||
|
||||
// feed it the messages its waiting for (create the files)
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(es3outs[0], "newfile."));
|
||||
@@ -1155,7 +1161,7 @@ namespace AssetProcessor
|
||||
{
|
||||
QString processFile1 = processResults[checkIdx].m_jobEntry.GetAbsoluteSourcePath();
|
||||
UNIT_TEST_EXPECT_TRUE(AssetUtilities::NormalizeFilePath(processFile1) == AssetUtilities::NormalizeFilePath(absolutePath));
|
||||
QString platformFolder = cacheRoot.filePath(QString::fromUtf8(processResults[checkIdx].m_jobEntry.m_platformInfo.m_identifier.c_str()) + "/" + gameName.toLower());
|
||||
QString platformFolder = cacheRoot.filePath(QString::fromUtf8(processResults[checkIdx].m_jobEntry.m_platformInfo.m_identifier.c_str()));
|
||||
platformFolder = AssetUtilities::NormalizeDirectoryPath(platformFolder);
|
||||
processFile1 = processResults[checkIdx].m_destinationPath;
|
||||
UNIT_TEST_EXPECT_TRUE(processFile1.startsWith(platformFolder));
|
||||
@@ -1261,7 +1267,7 @@ namespace AssetProcessor
|
||||
// 4 * file claimed for the produce file to be able to update it safely.
|
||||
// 4 * file released for the produce file so it's free for other tools to use it again.
|
||||
UNIT_TEST_EXPECT_TRUE(payloadList.size() == 9);
|
||||
unsigned int messageLoadCount = 0;
|
||||
unsigned int messageLoadCount = 0;
|
||||
for (auto payload : payloadList)
|
||||
{
|
||||
if (payload.first == SourceFileNotificationMessage::MessageType)
|
||||
@@ -1487,9 +1493,9 @@ namespace AssetProcessor
|
||||
|
||||
pcouts.clear();
|
||||
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/subfolder3/randomfileoutput.random"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/subfolder3/randomfileoutput.random1"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/subfolder3/randomfileoutput.random2"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/subfolder3/randomfileoutput.random")));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/subfolder3/randomfileoutput.random1")));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/subfolder3/randomfileoutput.random2")));
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(pcouts[0], "products."));
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(pcouts[1], "products."));
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(pcouts[2], "products."));
|
||||
@@ -1535,12 +1541,12 @@ namespace AssetProcessor
|
||||
es3outs2.clear();
|
||||
pcouts.clear();
|
||||
pcouts2.clear();
|
||||
es3outs.push_back(cacheRoot.filePath(QString("es3/") + gameName + "/basefilez.arc2"));
|
||||
es3outs2.push_back(cacheRoot.filePath(QString("es3/") + gameName + "/basefileaz.azm2"));
|
||||
es3outs.push_back(cacheRoot.filePath(QString("es3/basefilez.arc2")));
|
||||
es3outs2.push_back(cacheRoot.filePath(QString("es3/basefileaz.azm2")));
|
||||
// note that the ES3 outs have changed
|
||||
// but the pc outs are still the same.
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/basefile.arc2"));
|
||||
pcouts2.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/basefile.azm2"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/basefile.arc2")));
|
||||
pcouts2.push_back(cacheRoot.filePath(QString("pc/basefile.azm2")));
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(es3outs[0], "newfile."));
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(pcouts[0], "newfile."));
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(es3outs2[0], "newfile."));
|
||||
@@ -1629,7 +1635,7 @@ namespace AssetProcessor
|
||||
{
|
||||
QString processFile1 = processResults[checkIdx].m_jobEntry.GetAbsoluteSourcePath();
|
||||
UNIT_TEST_EXPECT_TRUE(processFile1 == expectedReplacementInputFile);
|
||||
QString platformFolder = cacheRoot.filePath(QString::fromUtf8(processResults[checkIdx].m_jobEntry.m_platformInfo.m_identifier.c_str()) + "/" + gameName.toLower());
|
||||
QString platformFolder = cacheRoot.filePath(QString::fromUtf8(processResults[checkIdx].m_jobEntry.m_platformInfo.m_identifier.c_str()));
|
||||
platformFolder = AssetUtilities::NormalizeDirectoryPath(platformFolder);
|
||||
processFile1 = processResults[checkIdx].m_destinationPath;
|
||||
UNIT_TEST_EXPECT_TRUE(processFile1.startsWith(platformFolder));
|
||||
@@ -1951,13 +1957,13 @@ namespace AssetProcessor
|
||||
}
|
||||
|
||||
UNIT_TEST_EXPECT_TRUE(BlockUntil(idling, 5000));
|
||||
|
||||
|
||||
// it now believes that there are a whole bunch of assets in subfolder1/done_renaming and they resulted in
|
||||
// a whole bunch of files to have been created in the asset cache, listed in processresults, and they exist in outputscreated...
|
||||
// rename the output folder:
|
||||
|
||||
QString originalCacheFolderName = normalizedCacheRootDir.absoluteFilePath("pc") + "/" + gameName.toLower() + "/done_renaming";
|
||||
QString newCacheFolderName = normalizedCacheRootDir.absoluteFilePath("pc") + "/" + gameName.toLower() + "/renamed_again";
|
||||
QString originalCacheFolderName = normalizedCacheRootDir.absoluteFilePath("pc") + "/done_renaming";
|
||||
QString newCacheFolderName = normalizedCacheRootDir.absoluteFilePath("pc") + "/renamed_again";
|
||||
|
||||
UNIT_TEST_EXPECT_TRUE(renamer.rename(originalCacheFolderName, newCacheFolderName));
|
||||
|
||||
@@ -2017,8 +2023,8 @@ namespace AssetProcessor
|
||||
|
||||
// setup complete. now RENAME that folder.
|
||||
|
||||
originalCacheFolderName = normalizedCacheRootDir.absoluteFilePath("pc") + "/" + gameName.toLower() + "/rename_this_secondly";
|
||||
newCacheFolderName = normalizedCacheRootDir.absoluteFilePath("pc") + "/" + gameName.toLower() + "/done_renaming_again";
|
||||
originalCacheFolderName = normalizedCacheRootDir.absoluteFilePath("pc") + "/rename_this_secondly";
|
||||
newCacheFolderName = normalizedCacheRootDir.absoluteFilePath("pc") + "/done_renaming_again";
|
||||
|
||||
UNIT_TEST_EXPECT_TRUE(renamer.rename(originalCacheFolderName, newCacheFolderName));
|
||||
|
||||
@@ -2305,8 +2311,7 @@ namespace AssetProcessor
|
||||
UnitTestUtils::ScopedDir changeDir(dir.path());
|
||||
QDir tempPath(dir.path());
|
||||
|
||||
// system is already actually initialized, along with gEnv, so this will always return that game name.
|
||||
QString gameName = AssetUtilities::ComputeGameName(AssetProcessorManagerTestGameProject);
|
||||
QString gameName = AssetUtilities::ComputeProjectName(AssetProcessorManagerTestGameProject);
|
||||
|
||||
// update the engine root
|
||||
AssetUtilities::ResetAssetRoot();
|
||||
@@ -2382,8 +2387,8 @@ namespace AssetProcessor
|
||||
UNIT_TEST_EXPECT_TRUE(processResults[0].m_jobEntry.m_jobKey.compare(processResults[1].m_jobEntry.m_jobKey) != 0);
|
||||
|
||||
QStringList pcouts;
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/basefile.arc1"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/basefile.arc2"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/basefile.arc1")));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/basefile.arc2")));
|
||||
|
||||
// Create the product files for the first job
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(pcouts[0], "product1"));
|
||||
@@ -2416,7 +2421,7 @@ namespace AssetProcessor
|
||||
UNIT_TEST_EXPECT_TRUE(AssetUtilities::NormalizeFilePath(changedInputResults[0].first) == AssetUtilities::NormalizeFilePath(sourceFile));
|
||||
|
||||
pcouts.clear();
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/basefile.arc3"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/basefile.arc3")));
|
||||
// Create the product files for the second job
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(pcouts[0], "product1"));
|
||||
|
||||
@@ -2515,9 +2520,7 @@ namespace AssetProcessor
|
||||
UnitTestUtils::ScopedDir changeDir(dir.path());
|
||||
QDir tempPath(dir.path());
|
||||
|
||||
|
||||
// system is already actually initialized, along with gEnv, so this will always return that game name.
|
||||
QString gameName = AssetUtilities::ComputeGameName(AssetProcessorManagerTestGameProject);
|
||||
QString gameName = AssetUtilities::ComputeProjectName(AssetProcessorManagerTestGameProject);
|
||||
|
||||
// update the engine root
|
||||
AssetUtilities::ResetAssetRoot();
|
||||
@@ -2745,7 +2748,7 @@ namespace AssetProcessor
|
||||
}
|
||||
response.m_result = AssetBuilderSDK::CreateJobsResultCode::Success;
|
||||
};
|
||||
|
||||
|
||||
AssetProcessor::AssetBuilderInfoBus::Handler::BusConnect();
|
||||
QDir oldRoot;
|
||||
AssetUtilities::ComputeAssetRoot(oldRoot);
|
||||
@@ -2757,8 +2760,7 @@ namespace AssetProcessor
|
||||
UnitTestUtils::ScopedDir changeDir(dir.path());
|
||||
QDir tempPath(dir.path());
|
||||
|
||||
// system is already actually initialized, along with gEnv, so this will always return that game name.
|
||||
QString gameName = AssetUtilities::ComputeGameName(AssetProcessorManagerTestGameProject);
|
||||
QString gameName = AssetUtilities::ComputeProjectName(AssetProcessorManagerTestGameProject);
|
||||
|
||||
// update the engine root
|
||||
AssetUtilities::ResetAssetRoot();
|
||||
@@ -2803,11 +2805,11 @@ namespace AssetProcessor
|
||||
QDir cacheRoot;
|
||||
UNIT_TEST_EXPECT_TRUE(AssetUtilities::ComputeProjectCacheRoot(cacheRoot));
|
||||
|
||||
QString productFileAPath = cacheRoot.filePath(QString("pc/") + gameName + "/FileAProduct.txt");
|
||||
QString productFileBPath = cacheRoot.filePath(QString("pc/") + gameName + "/FileBProduct1.txt");
|
||||
QString product2FileBPath = cacheRoot.filePath(QString("pc/") + gameName + "/FileBProduct2.txt");
|
||||
QString productFileCPath = cacheRoot.filePath(QString("pc/") + gameName + "/FileCProduct.txt");
|
||||
QString product2FileCPath = cacheRoot.filePath(QString("pc/") + gameName + "/FileCProduct2.txt");
|
||||
QString productFileAPath = cacheRoot.filePath(QString("pc/FileAProduct.txt"));
|
||||
QString productFileBPath = cacheRoot.filePath(QString("pc/FileBProduct1.txt"));
|
||||
QString product2FileBPath = cacheRoot.filePath(QString("pc/FileBProduct2.txt"));
|
||||
QString productFileCPath = cacheRoot.filePath(QString("pc/FileCProduct.txt"));
|
||||
QString product2FileCPath = cacheRoot.filePath(QString("pc/FileCProduct2.txt"));
|
||||
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(sourceFileAPath, ""));
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(sourceFileBPath, ""));
|
||||
@@ -2817,7 +2819,7 @@ namespace AssetProcessor
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(product2FileBPath, "product"));
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(productFileCPath, "product"));
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(product2FileCPath, "product"));
|
||||
|
||||
|
||||
// Analyze FileA
|
||||
QMetaObject::invokeMethod(&apm, "AssessAddedFile", Qt::QueuedConnection, Q_ARG(QString, sourceFileAPath));
|
||||
|
||||
@@ -2927,7 +2929,7 @@ namespace AssetProcessor
|
||||
{
|
||||
// Ensure that we are processing the right FileB job
|
||||
UNIT_TEST_EXPECT_TRUE(QString(jobDetail.m_jobEntry.m_jobKey).compare("yyy") == 0);
|
||||
|
||||
|
||||
response.m_outputProducts.clear();
|
||||
response.m_outputProducts.push_back(AssetBuilderSDK::JobProduct(product2FileBPath.toUtf8().constData()));
|
||||
QMetaObject::invokeMethod(&apm, "AssetProcessed", Qt::QueuedConnection, Q_ARG(JobEntry, jobDetail.m_jobEntry), Q_ARG(AssetBuilderSDK::ProcessJobResponse, response));
|
||||
@@ -2981,7 +2983,7 @@ namespace AssetProcessor
|
||||
|
||||
processResults.clear();
|
||||
// Modify fingerprint of Job("FileA", "xxx", "pc") and analyze FileA again,
|
||||
changeJobAFingerprint = false; // This will revert back the changes in the extra info used for fingerprinting of this job
|
||||
changeJobAFingerprint = false; // This will revert back the changes in the extra info used for fingerprinting of this job
|
||||
|
||||
QMetaObject::invokeMethod(&apm, "AssessModifiedFile", Qt::QueuedConnection, Q_ARG(QString, sourceFileAPath));
|
||||
|
||||
@@ -3001,7 +3003,7 @@ namespace AssetProcessor
|
||||
{
|
||||
// Verify FileB jobinfo
|
||||
UNIT_TEST_EXPECT_TRUE(QString(jobDetail.m_jobEntry.m_jobKey).compare("yyy") == 0);
|
||||
|
||||
|
||||
}
|
||||
else if (QString(jobDetail.m_jobEntry.m_pathRelativeToWatchFolder).endsWith("FileC.txt"))
|
||||
{
|
||||
@@ -3011,14 +3013,14 @@ namespace AssetProcessor
|
||||
}
|
||||
|
||||
|
||||
// Since one of the FileC job("FileC.txt","zzz") have emitted a job dependency on a FileB job("FileB.txt", "yyy")
|
||||
// which also have a job dependency on a FileA job("FileA.txt", "xxx") therefore deleting File A source file should
|
||||
// Since one of the FileC job("FileC.txt","zzz") have emitted a job dependency on a FileB job("FileB.txt", "yyy")
|
||||
// which also have a job dependency on a FileA job("FileA.txt", "xxx") therefore deleting File A source file should
|
||||
// cause both jobs (File B and File C) to be processed again.
|
||||
|
||||
|
||||
processResults.clear();
|
||||
|
||||
QFile::remove(sourceFileAPath);
|
||||
|
||||
|
||||
QMetaObject::invokeMethod(&apm, "AssessDeletedFile", Qt::QueuedConnection, Q_ARG(QString, sourceFileAPath));
|
||||
|
||||
UNIT_TEST_EXPECT_TRUE(BlockUntil(idling, 5000));
|
||||
@@ -3053,7 +3055,7 @@ namespace AssetProcessor
|
||||
|
||||
UNIT_TEST_EXPECT_TRUE(BlockUntil(idling, 5000));
|
||||
|
||||
|
||||
|
||||
UNIT_TEST_EXPECT_TRUE(processResults.size() == 3);
|
||||
|
||||
for (JobDetails& jobDetail : processResults)
|
||||
@@ -3091,15 +3093,14 @@ namespace AssetProcessor
|
||||
|
||||
// the canonicalization of the path here is to get around the fact that on some platforms
|
||||
// the "temporary" folder location could be junctioned into some other folder and getting "QDir::current()"
|
||||
// and other similar functions may actually return a different string but still be referring to the same folder
|
||||
// and other similar functions may actually return a different string but still be referring to the same folder
|
||||
QTemporaryDir dir;
|
||||
QDir tempPath(dir.path());
|
||||
QString canonicalTempDirPath = AssetUtilities::NormalizeDirectoryPath(tempPath.canonicalPath());
|
||||
UnitTestUtils::ScopedDir changeDir(canonicalTempDirPath);
|
||||
tempPath = QDir(canonicalTempDirPath);
|
||||
|
||||
// system is already actually initialized, along with gEnv, so this will always return that game name.
|
||||
QString gameName = AssetUtilities::ComputeGameName(AssetProcessorManagerTestGameProject);
|
||||
QString gameName = AssetUtilities::ComputeProjectName(AssetProcessorManagerTestGameProject);
|
||||
|
||||
// update the engine root
|
||||
AssetUtilities::ResetAssetRoot();
|
||||
@@ -3116,7 +3117,7 @@ namespace AssetProcessor
|
||||
|
||||
// note: the crux of this test is that we ar redirecting output into the cache at a different location instead of default.
|
||||
// so our scan folder has a "redirected" folder.
|
||||
config.AddScanFolder(ScanFolderInfo(tempPath.filePath("subfolder1"), "subfolder1", "subfolder1", "redirected", false, true, platforms, -1));
|
||||
config.AddScanFolder(ScanFolderInfo(tempPath.filePath("subfolder1"), "subfolder1", "subfolder1", "redirected", false, true, platforms, -1));
|
||||
|
||||
AssetProcessorManager_Test apm(&config);
|
||||
|
||||
@@ -3173,7 +3174,7 @@ namespace AssetProcessor
|
||||
UNIT_TEST_EXPECT_TRUE(processResults[0].m_jobEntry.m_watchFolderPath == tempPath.filePath("subfolder1"));
|
||||
|
||||
QStringList pcouts;
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/redirected/basefile.arc1"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/redirected/basefile.arc1")));
|
||||
|
||||
// Create the product files for the first job
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(pcouts[0], "product1"));
|
||||
@@ -3230,7 +3231,7 @@ namespace AssetProcessor
|
||||
UNIT_TEST_EXPECT_TRUE(processResults[0].m_jobEntry.m_databaseSourceName == "redirected/basefile.foo");
|
||||
UNIT_TEST_EXPECT_TRUE(processResults[0].m_jobEntry.m_watchFolderPath == tempPath.absoluteFilePath("subfolder1"));
|
||||
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/redirected/basefile.arc1"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/redirected/basefile.arc1")));
|
||||
|
||||
// Create the product files for the first job
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(pcouts[0], "product1"));
|
||||
@@ -3260,7 +3261,7 @@ namespace AssetProcessor
|
||||
assetMessages.clear();
|
||||
changedInputResults.clear();
|
||||
|
||||
QString deletedProductPath = cacheRoot.filePath(QString("pc/") + gameName + "/redirected/basefile.arc1");
|
||||
QString deletedProductPath = cacheRoot.filePath(QString("pc/redirected/basefile.arc1"));
|
||||
|
||||
QFile::remove(deletedProductPath);
|
||||
|
||||
@@ -3279,7 +3280,7 @@ namespace AssetProcessor
|
||||
UNIT_TEST_EXPECT_TRUE(processResults[0].m_jobEntry.m_databaseSourceName == "redirected/basefile.foo");
|
||||
UNIT_TEST_EXPECT_TRUE(processResults[0].m_jobEntry.m_watchFolderPath == tempPath.absoluteFilePath("subfolder1"));
|
||||
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/") + gameName + "/redirected/basefile.arc1"));
|
||||
pcouts.push_back(cacheRoot.filePath(QString("pc/redirected/basefile.arc1")));
|
||||
|
||||
// Create the product files for the first job
|
||||
UNIT_TEST_EXPECT_TRUE(CreateDummyFile(pcouts[0], "product1"));
|
||||
|
||||
@@ -78,9 +78,8 @@ void AssetProcessorServerUnitTest::RunFirstPartOfUnitTestsForAssetProcessorServe
|
||||
|
||||
void AssetProcessorServerUnitTest::RunAssetProcessorConnectionStressTest(bool failNegotiation)
|
||||
{
|
||||
AZStd::string azAppRoot = AZStd::string(QDir::current().absolutePath().toUtf8().constData());
|
||||
AZStd::string azBranchToken;
|
||||
AzFramework::ApplicationRequests::Bus::Broadcast(&AzFramework::ApplicationRequests::CalculateBranchTokenForAppRoot, azBranchToken);
|
||||
AzFramework::ApplicationRequests::Bus::Broadcast(&AzFramework::ApplicationRequests::CalculateBranchTokenForEngineRoot, azBranchToken);
|
||||
|
||||
QString branchToken(azBranchToken.c_str());
|
||||
|
||||
@@ -99,7 +98,7 @@ void AssetProcessorServerUnitTest::RunAssetProcessorConnectionStressTest(bool fa
|
||||
for (int idx = 0; idx < NUMBER_OF_TRIES; ++idx)
|
||||
{
|
||||
AzFramework::AssetSystem::AssetProcessorConnection connection;
|
||||
connection.Configure(branchToken.toUtf8().data(), "pc", "UNITTEST", AssetUtilities::ComputeGameName().toUtf8().constData()); // UNITTEST identifier will skip the processID validation during negotiation
|
||||
connection.Configure(branchToken.toUtf8().data(), "pc", "UNITTEST", AssetUtilities::ComputeProjectName().toUtf8().constData()); // UNITTEST identifier will skip the processID validation during negotiation
|
||||
connection.Connect("127.0.0.1", FEATURE_TEST_LISTEN_PORT);
|
||||
while (!connection.IsConnected() && !connection.NegotiationFailed())
|
||||
{
|
||||
|
||||
@@ -268,7 +268,7 @@ namespace UnitTestUtils
|
||||
|
||||
m_localFileIO->SetAlias("@assets@", (newDir + QString("/ALIAS/assets")).toUtf8().constData());
|
||||
m_localFileIO->SetAlias("@log@", (newDir + QString("/ALIAS/logs")).toUtf8().constData());
|
||||
m_localFileIO->SetAlias("@cache@", (newDir + QString("/ALIAS/cache")).toUtf8().constData());
|
||||
m_localFileIO->SetAlias("@usercache@", (newDir + QString("/ALIAS/cache")).toUtf8().constData());
|
||||
m_localFileIO->SetAlias("@user@", (newDir + QString("/ALIAS/user")).toUtf8().constData());
|
||||
m_localFileIO->SetAlias("@root@", (newDir + QString("/ALIAS/root")).toUtf8().constData());
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ using namespace AssetProcessor;
|
||||
namespace AssetProcessor
|
||||
{
|
||||
const char* const TEST_BOOTSTRAP_DATA =
|
||||
"sys_game_folder = TestProject \r\n\
|
||||
"project_path = TestProject \r\n\
|
||||
assets = pc \r\n\
|
||||
-- ip and port of the asset processor.Only if you need to change defaults \r\n\
|
||||
-- remote_ip = 127.0.0.1 \r\n\
|
||||
|
||||
Reference in New Issue
Block a user