DPE_AllComponentsAddedRemoved.py 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373
  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. SPDX-License-Identifier: Apache-2.0 OR MIT
  5. """
  6. animation_components = [
  7. "Actor",
  8. "Anim Graph",
  9. "Attachment",
  10. "Simple LOD Distance",
  11. "Simple Motion"
  12. ]
  13. audio_components = [
  14. "Audio Animation",
  15. "Audio Area Environment",
  16. "Audio Environment",
  17. "Audio Listener",
  18. "Audio Preload",
  19. "Audio Proxy",
  20. "Audio Rtpc",
  21. "Audio Switch",
  22. "Audio Trigger",
  23. "Multi-Position Audio"
  24. ]
  25. automated_testing_components = [
  26. "Network Test Level Entity",
  27. "Network Test Player",
  28. "Simple Script Player"
  29. ]
  30. camera_components = [
  31. "Camera",
  32. "Camera Rig"
  33. ]
  34. debugging_components = [
  35. "DebugDraw Line",
  36. "DebugDraw Obb",
  37. "DebugDraw Ray",
  38. "DebugDraw Sphere",
  39. "DebugDraw Text"
  40. ]
  41. editor_components = [
  42. "Comment"
  43. ]
  44. gameplay_components = [
  45. "Fly Camera Input",
  46. "Input",
  47. "Look At",
  48. "Random Timed Spawner",
  49. "Simple State",
  50. "Spawner",
  51. "Tag"
  52. ]
  53. gradient_modifier_components = [
  54. "Dither Gradient Modifier",
  55. "Gradient Mixer",
  56. "Gradient Transform Modifier",
  57. "Invert Gradient Modifier",
  58. "Levels Gradient Modifier",
  59. "Posterize Gradient Modifier",
  60. "Smooth-Step Gradient Modifier",
  61. "Threshold Gradient Modifier"
  62. ]
  63. gradient_components = [
  64. "Altitude Gradient",
  65. "Constant Gradient",
  66. "FastNoise Gradient",
  67. "Gradient Baker",
  68. "Image Gradient",
  69. "Perlin Noise Gradient",
  70. "Random Noise Gradient",
  71. "Reference Gradient",
  72. "Shape Falloff Gradient",
  73. "Slope Gradient",
  74. "Surface Mask Gradient"
  75. ]
  76. graphics_environment_components = [
  77. "Deferred Fog",
  78. "HDRi Skybox",
  79. "Physical Sky",
  80. "Sky Atmosphere",
  81. "Stars"
  82. ]
  83. graphics_lighting_components = [
  84. "CubeMap Capture",
  85. "Diffuse Probe Grid",
  86. "Directional Light",
  87. "Global Skylight (IBL)",
  88. "Light",
  89. "Reflection Probe"
  90. ]
  91. graphics_mesh_components = [
  92. "Atom Hair",
  93. "Decal",
  94. "Material",
  95. "Mesh"
  96. ]
  97. graphics_occlusion_components = [
  98. "Occlusion Culling Plane"
  99. ]
  100. other_components = [
  101. "Grid"
  102. ]
  103. postfx_components = [
  104. "Bloom",
  105. "Chromatic Aberration",
  106. "Depth Of Field",
  107. "Display Mapper",
  108. "Exposure Control",
  109. "HDR Color Grading",
  110. "Look Modification",
  111. "PostFX Gradient Weight Modifier",
  112. "PostFX Layer",
  113. "PostFX Radius Weight Modifier",
  114. "PostFX Shape Weight Modifier",
  115. "SSAO"
  116. ]
  117. input_components = [
  118. "Input Context"
  119. ]
  120. miscellaneous_components = [
  121. "Detour Navigation Component",
  122. "Entity Reference",
  123. "Recast Navigation Mesh",
  124. "Recast Navigation PhysX Provider"
  125. ]
  126. multiplayer_components = [
  127. "Local Prediction Player Input",
  128. "Network Binding",
  129. "Network Character",
  130. "Network Debug Player Id",
  131. "Network Hierarchy Child",
  132. "Network Hierarchy Root",
  133. "Network Hit Volumes",
  134. "Network Rigid Body",
  135. "Network Transform"
  136. ]
  137. physx_components = [
  138. "Cloth",
  139. "PhysX Ball Joint",
  140. "PhysX Character Controller",
  141. "PhysX Character Gameplay",
  142. "PhysX Dynamic Rigid Body",
  143. "PhysX Fixed Joint",
  144. "PhysX Force Region",
  145. "PhysX Heightfield Collider",
  146. "PhysX Hinge Joint",
  147. "PhysX Mesh Collider",
  148. "PhysX Primitive Collider",
  149. "PhysX Prismatic Joint",
  150. "PhysX Ragdoll",
  151. "PhysX Shape Collider",
  152. "PhysX Static Rigid Body"
  153. ]
  154. scripting_components = [
  155. "Lua Script",
  156. "Script Canvas"
  157. ]
  158. shape_components = [
  159. "Axis Aligned Box Shape",
  160. "Box Shape",
  161. "Capsule Shape",
  162. "Compound Shape",
  163. "Cylinder Shape",
  164. "Disk Shape",
  165. "Polygon Prism Shape",
  166. "Quad Shape",
  167. "Shape Reference",
  168. "Sphere Shape",
  169. "Spline",
  170. "Tube Shape",
  171. "White Box",
  172. "White Box Collider"
  173. ]
  174. surface_data_components = [
  175. "Gradient Surface Tag Emitter",
  176. "Mesh Surface Tag Emitter",
  177. "PhysX Collider Surface Tag Emitter",
  178. "Shape Surface Tag Emitter"
  179. ]
  180. terrain_components = [
  181. "Terrain Height Gradient List",
  182. "Terrain Layer Spawner",
  183. "Terrain Macro Material",
  184. "Terrain Physics Heightfield Collider",
  185. "Terrain Surface Gradient List",
  186. "Terrain Surface Materials List"
  187. ]
  188. test_components = [
  189. "AssetCollectionAsyncLoaderTest"
  190. ]
  191. ui_components = [
  192. "UI Canvas Asset Ref",
  193. "UI Canvas Proxy Ref",
  194. "UI Canvas on Mesh"
  195. ]
  196. vegetation_components = [
  197. "Landscape Canvas",
  198. "Vegetation Asset List",
  199. "Vegetation Asset List Combiner",
  200. "Vegetation Asset Weight Selector",
  201. "Vegetation Layer Blender",
  202. "Vegetation Layer Blocker",
  203. "Vegetation Layer Blocker (Mesh)",
  204. "Vegetation Layer Debugger",
  205. "Vegetation Layer Spawner"
  206. ]
  207. vegetation_filter_components = [
  208. "Vegetation Altitude Filter",
  209. "Vegetation Distance Between Filter",
  210. "Vegetation Distribution Filter",
  211. "Vegetation Shape Intersection Filter",
  212. "Vegetation Slope Filter",
  213. "Vegetation Surface Mask Depth Filter",
  214. "Vegetation Surface Mask Filter"
  215. ]
  216. vegetation_modifier_components = [
  217. "Vegetation Position Modifier",
  218. "Vegetation Rotation Modifier",
  219. "Vegetation Scale Modifier",
  220. "Vegetation Slope Alignment Modifier"
  221. ]
  222. all_component_categories = [
  223. animation_components,
  224. audio_components,
  225. automated_testing_components,
  226. camera_components,
  227. debugging_components,
  228. editor_components,
  229. gameplay_components,
  230. gradient_modifier_components,
  231. gradient_components,
  232. graphics_environment_components,
  233. graphics_lighting_components,
  234. graphics_mesh_components,
  235. graphics_occlusion_components,
  236. other_components,
  237. postfx_components,
  238. input_components,
  239. miscellaneous_components,
  240. multiplayer_components,
  241. physx_components,
  242. scripting_components,
  243. shape_components,
  244. surface_data_components,
  245. terrain_components,
  246. test_components,
  247. ui_components,
  248. vegetation_components,
  249. vegetation_filter_components,
  250. vegetation_modifier_components
  251. ]
  252. class Tests:
  253. dpe_enabled = (
  254. "DPE is enabled",
  255. "DPE is not enabled"
  256. )
  257. test_entity_created = (
  258. "Test entity created successfully",
  259. "Failed to create test entity"
  260. )
  261. def DPE_AllComponentsAddedRemoved():
  262. """
  263. With the DPE Enabled, validates that every component available in the AutomatedTesting project can be successfully
  264. added and removed from an entity.
  265. """
  266. import azlmbr.legacy.general as general
  267. from editor_python_test_tools.utils import TestHelper, Report, Tracer
  268. from editor_python_test_tools.editor_entity_utils import EditorEntity
  269. def add_remove_component(component_name):
  270. # Create a new entity for component operations
  271. entity = EditorEntity.create_editor_entity()
  272. Report.critical_result(Tests.test_entity_created, entity.exists())
  273. # Add the specified component and validate
  274. entity.add_component(component_name)
  275. component_added = TestHelper.wait_for_condition(lambda: entity.has_component(component_name), 5.0)
  276. assert component_added, f"Failed to add {component_name} to entity"
  277. # Undo the component add and validate
  278. general.undo()
  279. undo_removes_component = TestHelper.wait_for_condition(lambda: not entity.has_component(component_name), 5.0)
  280. assert undo_removes_component, f"Undo failed: {component_name} still found on entity"
  281. # Redo the component add and validate
  282. general.redo()
  283. redo_readds_component = TestHelper.wait_for_condition(lambda: entity.has_component(component_name), 5.0)
  284. assert redo_readds_component, f"Redo failed: {component_name} not found on entity"
  285. # Remove the component and validate
  286. entity.remove_component(component_name)
  287. component_removed = TestHelper.wait_for_condition(lambda: not entity.has_component(component_name), 5.0)
  288. assert component_removed, f"Failed to remove {component_name} from entity"
  289. # Undo the removal and validate
  290. general.undo()
  291. undo_readds_component = TestHelper.wait_for_condition(lambda: entity.has_component(component_name), 5.0)
  292. assert undo_readds_component, f"Undo failed: {component_name} not found on entity"
  293. # Redo the removal and validate
  294. general.redo()
  295. redo_removes_component = TestHelper.wait_for_condition(lambda: not entity.has_component(component_name), 5.0)
  296. assert redo_removes_component, f"Redo failed: {component_name} still found on entity"
  297. # Delete the test entity, and return True if we have not triggered an assertion
  298. entity.delete()
  299. return True
  300. with Tracer() as error_tracer:
  301. # Open the base level
  302. TestHelper.init_idle()
  303. TestHelper.open_level("", "Base")
  304. # Verify the DPE is enabled
  305. Report.critical_result(Tests.dpe_enabled, general.get_cvar("ed_enableDPEInspector") == "true")
  306. # Loop through list of components
  307. for component_category in all_component_categories:
  308. for component in component_category:
  309. component_results = (
  310. f"{component} component: All Add/Remove operations successful",
  311. f"{component} component: Add/Remove operation(s) failed"
  312. )
  313. Report.result(component_results, add_remove_component(component))
  314. # Look for errors and asserts
  315. TestHelper.wait_for_condition(lambda: error_tracer.has_errors or error_tracer.has_asserts, 1.0)
  316. for error_info in error_tracer.errors:
  317. Report.info(f"Error: {error_info.filename} {error_info.function} | {error_info.message}")
  318. for assert_info in error_tracer.asserts:
  319. Report.info(f"Assert: {assert_info.filename} {assert_info.function} | {assert_info.message}")
  320. if __name__ == "__main__":
  321. from editor_python_test_tools.utils import Report
  322. Report.start_test(DPE_AllComponentsAddedRemoved)