{LYN-4996} Asset Processor is not reprocessing STL files after settings are edited/updated (#2095)

* add asset importer file extension

Signed-off-by: sharmajs <sharmajs@amazon.com>

* add new test setreg file

Signed-off-by: sharmajs <sharmajs@amazon.com>

* removed an unnecessary namespace

Signed-off-by: sharmajs <sharmajs@amazon.com>

* addressed feedback

Signed-off-by: sharmajs <sharmajs@amazon.com>

* addressed feedback

Signed-off-by: sharmajs <sharmajs@amazon.com>

* remove unnecessay method

Signed-off-by: sharmajs <sharmajs@amazon.com>

* add file

Signed-off-by: sharmajs <sharmajs@amazon.com>

* reduce waiting time in block until idle

Signed-off-by: sharmajs <sharmajs@amazon.com>
This commit is contained in:
sharmajs-amzn
2021-07-20 09:26:11 -07:00
committed by GitHub
parent 00f50f2a90
commit d5431e1c57
10 changed files with 161 additions and 2 deletions
@@ -76,6 +76,7 @@ public:
friend class GTEST_TEST_CLASS_NAME_(ModtimeScanningTest, ModtimeSkipping_ModifyMetadataFile);
friend class GTEST_TEST_CLASS_NAME_(ModtimeScanningTest, ModtimeSkipping_DeleteFile);
friend class GTEST_TEST_CLASS_NAME_(DeleteTest, DeleteFolderSharedAcrossTwoScanFolders_CorrectFileAndFolderAreDeletedFromCache);
friend class GTEST_TEST_CLASS_NAME_(MetadataFileTest, MetadataFile_SourceFileExtensionDifferentCase);
friend class AssetProcessorManagerTest;
friend struct ModtimeScanningTest;
@@ -5241,3 +5242,59 @@ void DuplicateProcessTest::SetUp()
m_sharedConnection = m_assetProcessorManager->m_stateData.get();
ASSERT_TRUE(m_sharedConnection);
}
void MetadataFileTest::SetUp()
{
AssetProcessorManagerTest::SetUp();
m_config->AddMetaDataType("foo", "txt");
}
TEST_F(MetadataFileTest, MetadataFile_SourceFileExtensionDifferentCase)
{
using namespace AzToolsFramework::AssetSystem;
using namespace AssetProcessor;
QDir tempPath(m_tempDir.path());
QString relFileName("Dummy.TXT");
QString absPath(tempPath.absoluteFilePath("subfolder1/Dummy.TXT"));
QString watchFolder = tempPath.absoluteFilePath("subfolder1");
UnitTestUtils::CreateDummyFile(absPath, "dummy");
JobEntry entry;
entry.m_watchFolderPath = watchFolder;
entry.m_databaseSourceName = entry.m_pathRelativeToWatchFolder = relFileName;
entry.m_jobKey = "txt";
entry.m_platformInfo = { "pc", {"host", "renderer", "desktop"} };
entry.m_jobRunKey = 1;
QString productPath(m_normalizedCacheRootDir.absoluteFilePath("outputfile.TXT"));
UnitTestUtils::CreateDummyFile(productPath);
AssetBuilderSDK::ProcessJobResponse jobResponse;
jobResponse.m_resultCode = AssetBuilderSDK::ProcessJobResult_Success;
jobResponse.m_outputProducts.push_back(AssetBuilderSDK::JobProduct(productPath.toUtf8().data()));
QMetaObject::invokeMethod(m_assetProcessorManager.get(), "AssetProcessed", Qt::QueuedConnection, Q_ARG(JobEntry, entry), Q_ARG(AssetBuilderSDK::ProcessJobResponse, jobResponse));
ASSERT_TRUE(BlockUntilIdle(5000));
// Creating a metadata file for the source assets
// APM should process the source asset if a metadafile is detected
// We are intentionally having a source file with a different file extension casing than the one specified in the metadata rule.
QString metadataFile(tempPath.absoluteFilePath("subfolder1/Dummy.foo"));
UnitTestUtils::CreateDummyFile(metadataFile, "dummy");
// Capture the job details as the APM inspects the file.
JobDetails jobDetails;
auto connection = QObject::connect(m_assetProcessorManager.get(), &AssetProcessorManager::AssetToProcess, [&jobDetails](JobDetails job)
{
jobDetails = job;
});
m_assetProcessorManager->AssessAddedFile(tempPath.absoluteFilePath(metadataFile));
ASSERT_TRUE(BlockUntilIdle(5000));
ASSERT_EQ(jobDetails.m_jobEntry.m_pathRelativeToWatchFolder, relFileName);
}
@@ -179,6 +179,13 @@ struct ModtimeScanningTest
AZStd::unique_ptr<StaticData> m_data;
};
struct MetadataFileTest
: public AssetProcessorManagerTest
{
void SetUp() override;
};
struct FingerprintTest
: public AssetProcessorManagerTest
{
@@ -21,6 +21,7 @@ class UnitTestPlatformConfiguration : public AssetProcessor::PlatformConfigurati
{
friend class GTEST_TEST_CLASS_NAME_(PlatformConfigurationUnitTests, Test_GemHandling);
friend class GTEST_TEST_CLASS_NAME_(PlatformConfigurationUnitTests, Test_MetaFileTypes);
friend class GTEST_TEST_CLASS_NAME_(PlatformConfigurationUnitTests, Test_MetaFileTypes_AssetImporterExtensions);
protected:
};
@@ -665,3 +666,24 @@ TEST_F(PlatformConfigurationUnitTests, PlatformConfigFile_IsPresent_Found)
ASSERT_TRUE(config.AddPlatformConfigFilePaths(platformConfigList));
ASSERT_EQ(platformConfigList.size(), 1);
}
TEST_F(PlatformConfigurationUnitTests, Test_MetaFileTypes_AssetImporterExtensions)
{
using namespace AssetProcessor;
const auto testExeFolder = AZ::IO::FileIOBase::GetInstance()->ResolvePath(TestAppRoot);
auto configRoot = AZ::IO::FileIOBase::GetInstance()->ResolvePath("@exefolder@/testdata/config_metadata");
ASSERT_TRUE(configRoot);
UnitTestPlatformConfiguration config;
m_absorber.Clear();
ASSERT_FALSE(config.InitializeFromConfigFiles(configRoot->c_str(), testExeFolder->c_str(), EmptyDummyProjectName, false, false));
ASSERT_GT(m_absorber.m_numErrorsAbsorbed, 0);
ASSERT_TRUE(config.MetaDataFileTypesCount() == 2);
QStringList entriesToTest{ "aaa", "bbb" };
for (int idx = 0; idx < entriesToTest.size(); idx++)
{
ASSERT_EQ(config.GetMetaDataFileTypeAt(idx).first, QString("%1.assetinfo").arg(entriesToTest[idx]));
ASSERT_EQ(config.GetMetaDataFileTypeAt(idx).second, QString("%1").arg(entriesToTest[idx]));
}
}