InitialScanSkippingTests.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <tests/assetmanager/AssetManagerTestingBase.h>
  9. #include <AzCore/Utils/Utils.h>
  10. #include <native/AssetManager/assetScanFolderInfo.h>
  11. namespace UnitTests
  12. {
  13. using InitialScanSkipTests = AssetManagerTestingBase;
  14. TEST_F(InitialScanSkipTests, SanityTest_SkippingDisabled_ProcessesAFile)
  15. {
  16. using namespace AssetProcessor;
  17. // This pair of tests are regression tests for an issue where having scan skipping turned on would result in AP never processing
  18. // files This particular test verifies everything works when scan skipping is off
  19. QSet<AssetProcessor::AssetFileInfo> filePaths = {};
  20. // Simulate running through the scanning phase
  21. QMetaObject::invokeMethod(
  22. m_assetProcessorManager.get(),
  23. "OnAssetScannerStatusChange",
  24. Qt::QueuedConnection,
  25. Q_ARG(AssetProcessor::AssetScanningStatus, AssetProcessor::AssetScanningStatus::Started));
  26. QMetaObject::invokeMethod(
  27. m_assetProcessorManager.get(), "AssessFilesFromScanner", Qt::QueuedConnection, Q_ARG(QSet<AssetFileInfo>, filePaths));
  28. QMetaObject::invokeMethod(
  29. m_assetProcessorManager.get(),
  30. "OnAssetScannerStatusChange",
  31. Qt::QueuedConnection,
  32. Q_ARG(AssetProcessor::AssetScanningStatus, AssetProcessor::AssetScanningStatus::Completed));
  33. CreateBuilder("stage1", "*.stage1", "stage2", false, AssetBuilderSDK::ProductOutputFlags::ProductAsset);
  34. // Test with scan skipping off
  35. m_assetProcessorManager->SetInitialScanSkippingFeature(false);
  36. // Update the file
  37. AZ::Utils::WriteFile("unit test file", m_testFilePath.c_str());
  38. // Process the file
  39. ProcessFileMultiStage(1, true);
  40. }
  41. TEST_F(InitialScanSkipTests, SkippingEnabled_ProcessesAFile)
  42. {
  43. using namespace AssetProcessor;
  44. // This pair of tests are regression tests for an issue where having scan skipping turned on would result in AP never processing
  45. // files This particular test verifies files can be processed after scanning is done when scan skipping is enabled
  46. QSet<AssetProcessor::AssetFileInfo> filePaths = {};
  47. QMetaObject::invokeMethod(
  48. m_assetProcessorManager.get(),
  49. "OnAssetScannerStatusChange",
  50. Qt::QueuedConnection,
  51. Q_ARG(AssetProcessor::AssetScanningStatus, AssetProcessor::AssetScanningStatus::Started));
  52. QMetaObject::invokeMethod(
  53. m_assetProcessorManager.get(), "AssessFilesFromScanner", Qt::QueuedConnection, Q_ARG(QSet<AssetFileInfo>, filePaths));
  54. QMetaObject::invokeMethod(
  55. m_assetProcessorManager.get(),
  56. "OnAssetScannerStatusChange",
  57. Qt::QueuedConnection,
  58. Q_ARG(AssetProcessor::AssetScanningStatus, AssetProcessor::AssetScanningStatus::Completed));
  59. CreateBuilder("stage1", "*.stage1", "stage2", false, AssetBuilderSDK::ProductOutputFlags::ProductAsset);
  60. m_assetProcessorManager->SetInitialScanSkippingFeature(true);
  61. AZ::Utils::WriteFile("unit test file", m_testFilePath.c_str());
  62. ProcessFileMultiStage(1, true);
  63. }
  64. } // namespace UnitTests