AssetBuilderSDKBehaviorTests.cpp 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435
  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 "assetBuilderSDKTest.h"
  9. #include <AssetBuilderSDK/AssetBuilderSDK.h>
  10. #include <AzCore/Component/ComponentApplication.h>
  11. #include <AzCore/RTTI/AttributeReader.h>
  12. #include <AzCore/RTTI/BehaviorContext.h>
  13. #include <AzCore/Script/ScriptContextAttributes.h>
  14. #include <AzCore/UnitTest/TestTypes.h>
  15. #include "native/tests/BaseAssetProcessorTest.h"
  16. #include "native/unittests/UnitTestRunner.h"
  17. namespace AssetProcessor
  18. {
  19. struct AssetBehaviorContextTest
  20. : public ::testing::Test
  21. {
  22. struct DataMembers
  23. {
  24. UnitTestUtils::AssertAbsorber m_absorber;
  25. DataMembers() = default;
  26. };
  27. // the component application creates and returns a system entity, but doesn't keep track of it
  28. AZ::Entity* m_systemEntity = nullptr;
  29. // store all data we create here so that it can be destroyed on shutdown before we remove allocators
  30. DataMembers* m_data = nullptr;
  31. // the app is created separately so that we can control its lifetime.
  32. AZStd::unique_ptr<AZ::ComponentApplication> m_app;
  33. void SetUp() override
  34. {
  35. m_app.reset(aznew AZ::ComponentApplication());
  36. AZ::ComponentApplication::Descriptor desc;
  37. m_systemEntity = m_app->Create(desc);
  38. AssetBuilderSDK::InitializeSerializationContext();
  39. AssetBuilderSDK::InitializeBehaviorContext();
  40. m_data = azcreate(DataMembers, ());
  41. }
  42. void TearDown() override
  43. {
  44. EXPECT_EQ(0, m_data->m_absorber.m_numAssertsAbsorbed);
  45. EXPECT_EQ(0, m_data->m_absorber.m_numErrorsAbsorbed);
  46. EXPECT_EQ(0, m_data->m_absorber.m_numWarningsAbsorbed);
  47. azdestroy(m_data);
  48. delete m_systemEntity;
  49. m_systemEntity = nullptr;
  50. m_app->Destroy();
  51. m_app.reset();
  52. }
  53. bool IsBehaviorFlaggedForEditor(const AZ::AttributeArray& attributes)
  54. {
  55. AZ::Script::Attributes::ScopeFlags scopeType = AZ::Script::Attributes::ScopeFlags::Launcher;
  56. AZ::Attribute* scopeAttribute = AZ::FindAttribute(AZ::Script::Attributes::Scope, attributes);
  57. if (scopeAttribute)
  58. {
  59. AZ::AttributeReader scopeAttributeReader(nullptr, scopeAttribute);
  60. scopeAttributeReader.Read<AZ::Script::Attributes::ScopeFlags>(scopeType);
  61. }
  62. return (scopeType == AZ::Script::Attributes::ScopeFlags::Automation ||
  63. scopeType == AZ::Script::Attributes::ScopeFlags::Common);
  64. }
  65. };
  66. TEST_F(AssetBehaviorContextTest, DetectBehaviorAssetBuilderPattern)
  67. {
  68. auto&& behaviorContext = m_app->GetBehaviorContext();
  69. auto behaviorClassEntry = behaviorContext->m_classes.find("AssetBuilderPattern");
  70. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  71. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  72. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  73. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("type"));
  74. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("pattern"));
  75. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("Regex"));
  76. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("Wildcard"));
  77. EXPECT_EQ(1, behaviorClass->m_constructors.size());
  78. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorContext->m_classes.find("AZStd::vector<AssetBuilderPattern, allocator>"));
  79. }
  80. TEST_F(AssetBehaviorContextTest, DetectBehaviorJobDescriptor)
  81. {
  82. auto&& behaviorContext = m_app->GetBehaviorContext();
  83. auto behaviorClassEntry = behaviorContext->m_classes.find("JobDescriptor");
  84. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  85. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  86. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  87. EXPECT_TRUE(behaviorClass->m_methods.end() != behaviorClass->m_methods.find("set_platform_identifier"));
  88. EXPECT_TRUE(behaviorClass->m_methods.end() != behaviorClass->m_methods.find("get_platform_identifier"));
  89. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("jobParameters"));
  90. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("additionalFingerprintInfo"));
  91. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("priority"));
  92. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("checkExclusiveLock"));
  93. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("checkServer"));
  94. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("jobDependencyList"));
  95. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("failOnError"));
  96. EXPECT_EQ(2, behaviorClass->m_constructors.size());
  97. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorContext->m_classes.find("AZStd::vector<JobDescriptor, allocator>"));
  98. }
  99. TEST_F(AssetBehaviorContextTest, DetectBehaviorProductDependency)
  100. {
  101. auto&& behaviorContext = m_app->GetBehaviorContext();
  102. auto behaviorClassEntry = behaviorContext->m_classes.find("ProductDependency");
  103. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  104. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  105. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  106. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("dependencyId"));
  107. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("flags"));
  108. EXPECT_EQ(1, behaviorClass->m_constructors.size());
  109. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorContext->m_classes.find("AZStd::vector<ProductDependency, allocator>"));
  110. }
  111. TEST_F(AssetBehaviorContextTest, DetectBehaviorJobProduct)
  112. {
  113. auto&& behaviorContext = m_app->GetBehaviorContext();
  114. auto behaviorClassEntry = behaviorContext->m_classes.find("JobProduct");
  115. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  116. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  117. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  118. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("productFileName"));
  119. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("productAssetType"));
  120. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("productSubID"));
  121. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("productDependencies"));
  122. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("pathDependencies"));
  123. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("dependenciesHandled"));
  124. EXPECT_EQ(2, behaviorClass->m_constructors.size());
  125. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorContext->m_classes.find("AZStd::vector<JobProduct, allocator>"));
  126. }
  127. TEST_F(AssetBehaviorContextTest, DetectBehaviorProcessJobRequest)
  128. {
  129. auto&& behaviorContext = m_app->GetBehaviorContext();
  130. auto behaviorClassEntry = behaviorContext->m_classes.find("ProcessJobRequest");
  131. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  132. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  133. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  134. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("sourceFile"));
  135. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("watchFolder"));
  136. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("fullPath"));
  137. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("builderGuid"));
  138. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("jobDescription"));
  139. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("tempDirPath"));
  140. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("platformInfo"));
  141. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("sourceFileDependencyList"));
  142. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("sourceFileUUID"));
  143. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("jobId"));
  144. EXPECT_EQ(0, behaviorClass->m_constructors.size());
  145. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorContext->m_classes.find("AZStd::vector<SourceFileDependency, allocator>"));
  146. }
  147. TEST_F(AssetBehaviorContextTest, DetectBehaviorSourceFileDependency)
  148. {
  149. auto&& behaviorContext = m_app->GetBehaviorContext();
  150. auto behaviorClassEntry = behaviorContext->m_classes.find("SourceFileDependency");
  151. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  152. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  153. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  154. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("sourceFileDependencyPath"));
  155. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("sourceFileDependencyUUID"));
  156. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("sourceDependencyType"));
  157. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("Absolute"));
  158. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("Wildcards"));
  159. EXPECT_EQ(2, behaviorClass->m_constructors.size());
  160. }
  161. TEST_F(AssetBehaviorContextTest, DetectBehaviorAssetBuilderDesc)
  162. {
  163. auto&& behaviorContext = m_app->GetBehaviorContext();
  164. auto behaviorClassEntry = behaviorContext->m_classes.find("AssetBuilderDesc");
  165. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  166. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  167. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  168. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("analysisFingerprint"));
  169. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("busId"));
  170. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("flags"));
  171. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("name"));
  172. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("patterns"));
  173. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("version"));
  174. EXPECT_EQ(1, behaviorClass->m_constructors.size());
  175. }
  176. TEST_F(AssetBehaviorContextTest, DetectBehaviorCreateJobsResponse)
  177. {
  178. auto&& behaviorContext = m_app->GetBehaviorContext();
  179. auto behaviorClassEntry = behaviorContext->m_classes.find("CreateJobsResponse");
  180. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  181. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  182. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  183. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("result"));
  184. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("sourceFileDependencyList"));
  185. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("createJobOutputs"));
  186. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("ResultFailed"));
  187. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("ResultShuttingDown"));
  188. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("ResultSuccess"));
  189. EXPECT_EQ(0, behaviorClass->m_constructors.size());
  190. }
  191. TEST_F(AssetBehaviorContextTest, DetectBehaviorCreateJobsRequest)
  192. {
  193. auto&& behaviorContext = m_app->GetBehaviorContext();
  194. auto behaviorClassEntry = behaviorContext->m_classes.find("CreateJobsRequest");
  195. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  196. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  197. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  198. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("builderId"));
  199. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("watchFolder"));
  200. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("sourceFile"));
  201. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("sourceFileUUID"));
  202. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("enabledPlatforms"));
  203. EXPECT_EQ(0, behaviorClass->m_constructors.size());
  204. }
  205. TEST_F(AssetBehaviorContextTest, DetectBehaviorProductPathDependency)
  206. {
  207. auto&& behaviorContext = m_app->GetBehaviorContext();
  208. auto behaviorClassEntry = behaviorContext->m_classes.find("ProductPathDependency");
  209. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  210. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  211. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  212. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("dependencyPath"));
  213. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("dependencyType"));
  214. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("ProductFile"));
  215. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("SourceFile"));
  216. EXPECT_EQ(0, behaviorClass->m_constructors.size());
  217. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorContext->m_classes.find("AZStd::vector<ProductPathDependency, allocator>"));
  218. }
  219. TEST_F(AssetBehaviorContextTest, DetectBehaviorProcessJobResponse)
  220. {
  221. auto&& behaviorContext = m_app->GetBehaviorContext();
  222. auto behaviorClassEntry = behaviorContext->m_classes.find("ProcessJobResponse");
  223. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  224. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  225. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  226. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("outputProducts"));
  227. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("resultCode"));
  228. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("requiresSubIdGeneration"));
  229. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("sourcesToReprocess"));
  230. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("Success"));
  231. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("Failed"));
  232. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("Crashed"));
  233. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("Cancelled"));
  234. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("NetworkIssue"));
  235. EXPECT_EQ(0, behaviorClass->m_constructors.size());
  236. }
  237. TEST_F(AssetBehaviorContextTest, DetectBehaviorRegisterBuilderResponse)
  238. {
  239. auto&& behaviorContext = m_app->GetBehaviorContext();
  240. auto behaviorClassEntry = behaviorContext->m_classes.find("RegisterBuilderResponse");
  241. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  242. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  243. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  244. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("assetBuilderDescList"));
  245. EXPECT_EQ(1, behaviorClass->m_constructors.size());
  246. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorContext->m_classes.find("AZStd::vector<AssetBuilderDesc, allocator>"));
  247. }
  248. TEST_F(AssetBehaviorContextTest, DetectBehaviorRegisterBuilderRequest)
  249. {
  250. auto&& behaviorContext = m_app->GetBehaviorContext();
  251. auto behaviorClassEntry = behaviorContext->m_classes.find("RegisterBuilderRequest");
  252. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  253. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  254. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  255. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("filePath"));
  256. EXPECT_EQ(0, behaviorClass->m_constructors.size());
  257. }
  258. TEST_F(AssetBehaviorContextTest, DetectBehaviorJobDependency)
  259. {
  260. auto&& behaviorContext = m_app->GetBehaviorContext();
  261. auto behaviorClassEntry = behaviorContext->m_classes.find("JobDependency");
  262. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  263. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  264. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  265. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("sourceFile"));
  266. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("jobKey"));
  267. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("platformIdentifier"));
  268. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("type"));
  269. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("Fingerprint"));
  270. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("Order"));
  271. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("OrderOnce"));
  272. EXPECT_EQ(0, behaviorClass->m_constructors.size());
  273. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorContext->m_classes.find("AZStd::vector<JobDependency, allocator>"));
  274. }
  275. TEST_F(AssetBehaviorContextTest, DetectBehaviorPlatformInfo)
  276. {
  277. auto&& behaviorContext = m_app->GetBehaviorContext();
  278. auto behaviorClassEntry = behaviorContext->m_classes.find("PlatformInfo");
  279. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorClassEntry);
  280. AZ::BehaviorClass* behaviorClass = behaviorClassEntry->second;
  281. EXPECT_TRUE(IsBehaviorFlaggedForEditor(behaviorClass->m_attributes));
  282. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("identifier"));
  283. EXPECT_TRUE(behaviorClass->m_properties.end() != behaviorClass->m_properties.find("tags"));
  284. EXPECT_EQ(0, behaviorClass->m_constructors.size());
  285. EXPECT_TRUE(behaviorContext->m_classes.end() != behaviorContext->m_classes.find("AZStd::vector<PlatformInfo, allocator>"));
  286. }
  287. template <typename T>
  288. bool EnumClassReadUpdateTest(AZ::BehaviorProperty* behaviorProperty, AZ::BehaviorObject& instance, T value)
  289. {
  290. T enumClassTypeValue = {};
  291. EXPECT_TRUE(behaviorProperty->m_setter->Invoke(instance, value));
  292. EXPECT_TRUE(behaviorProperty->m_getter->InvokeResult(enumClassTypeValue, instance));
  293. EXPECT_EQ(value, enumClassTypeValue);
  294. return value == enumClassTypeValue;
  295. }
  296. TEST_F(AssetBehaviorContextTest, DISABLED_EnumClass_ProductPathDependencyType_Accessible)
  297. {
  298. using namespace AssetBuilderSDK;
  299. auto&& behaviorContext = m_app->GetBehaviorContext();
  300. auto&& behaviorClassEntry = behaviorContext->m_classes.find("ProductPathDependency");
  301. auto&& behaviorClass = behaviorClassEntry->second;
  302. auto&& behaviorProperty = behaviorClass->m_properties["dependencyType"];
  303. auto instance = behaviorClass->Create();
  304. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, ProductPathDependencyType::ProductFile));
  305. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, ProductPathDependencyType::SourceFile));
  306. behaviorClass->Destroy(instance);
  307. }
  308. TEST_F(AssetBehaviorContextTest, DISABLED_EnumClass_AssetBuilderPatternPatternType_Accessible)
  309. {
  310. using namespace AssetBuilderSDK;
  311. auto&& behaviorContext = m_app->GetBehaviorContext();
  312. auto&& behaviorClassEntry = behaviorContext->m_classes.find("AssetBuilderPattern");
  313. auto&& behaviorClass = behaviorClassEntry->second;
  314. auto&& behaviorProperty = behaviorClass->m_properties["type"];
  315. auto instance = behaviorClass->Create();
  316. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, AssetBuilderPattern::PatternType::Wildcard));
  317. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, AssetBuilderPattern::PatternType::Regex));
  318. behaviorClass->Destroy(instance);
  319. }
  320. TEST_F(AssetBehaviorContextTest, DISABLED_EnumClass_ProcessJobResponse_Accessible)
  321. {
  322. using namespace AssetBuilderSDK;
  323. auto&& behaviorContext = m_app->GetBehaviorContext();
  324. auto&& behaviorClassEntry = behaviorContext->m_classes.find("ProcessJobResponse");
  325. auto&& behaviorClass = behaviorClassEntry->second;
  326. auto&& behaviorProperty = behaviorClass->m_properties["resultCode"];
  327. auto instance = behaviorClass->Create();
  328. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, ProcessJobResultCode::ProcessJobResult_Success));
  329. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, ProcessJobResultCode::ProcessJobResult_Failed));
  330. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, ProcessJobResultCode::ProcessJobResult_Crashed));
  331. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, ProcessJobResultCode::ProcessJobResult_Cancelled));
  332. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, ProcessJobResultCode::ProcessJobResult_NetworkIssue));
  333. behaviorClass->Destroy(instance);
  334. }
  335. TEST_F(AssetBehaviorContextTest, DISABLED_EnumClass_JobDependencyType_Accessible)
  336. {
  337. using namespace AssetBuilderSDK;
  338. auto&& behaviorContext = m_app->GetBehaviorContext();
  339. auto&& behaviorClassEntry = behaviorContext->m_classes.find("JobDependency");
  340. auto&& behaviorClass = behaviorClassEntry->second;
  341. auto&& behaviorProperty = behaviorClass->m_properties["type"];
  342. auto instance = behaviorClass->Create();
  343. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, JobDependencyType::Fingerprint));
  344. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, JobDependencyType::Order));
  345. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, JobDependencyType::OrderOnce));
  346. behaviorClass->Destroy(instance);
  347. }
  348. TEST_F(AssetBehaviorContextTest, DISABLED_EnumClass_CreateJobsResultCode_Accessible)
  349. {
  350. using namespace AssetBuilderSDK;
  351. auto&& behaviorContext = m_app->GetBehaviorContext();
  352. auto&& behaviorClassEntry = behaviorContext->m_classes.find("CreateJobsResponse");
  353. auto&& behaviorClass = behaviorClassEntry->second;
  354. auto&& behaviorProperty = behaviorClass->m_properties["result"];
  355. auto instance = behaviorClass->Create();
  356. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, CreateJobsResultCode::Failed));
  357. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, CreateJobsResultCode::ShuttingDown));
  358. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, CreateJobsResultCode::Success));
  359. behaviorClass->Destroy(instance);
  360. }
  361. TEST_F(AssetBehaviorContextTest, DISABLED_EnumClass_SourceFileDependency_Accessible)
  362. {
  363. using namespace AssetBuilderSDK;
  364. auto&& behaviorContext = m_app->GetBehaviorContext();
  365. auto&& behaviorClassEntry = behaviorContext->m_classes.find("SourceFileDependency");
  366. auto&& behaviorClass = behaviorClassEntry->second;
  367. auto&& behaviorProperty = behaviorClass->m_properties["sourceDependencyType"];
  368. auto instance = behaviorClass->Create();
  369. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, SourceFileDependency::SourceFileDependencyType::Absolute));
  370. EXPECT_TRUE(EnumClassReadUpdateTest(behaviorProperty, instance, SourceFileDependency::SourceFileDependencyType::Wildcards));
  371. behaviorClass->Destroy(instance);
  372. }
  373. };