fbx_tests.py 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852
  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. import binascii
  7. from dataclasses import dataclass
  8. import logging
  9. import os
  10. import pytest
  11. from typing import List
  12. import distutils.dir_util
  13. # Import LyTestTools
  14. import ly_test_tools.builtin.helpers as helpers
  15. from ly_test_tools.o3de import asset_processor as asset_processor_utils
  16. from ly_test_tools.o3de.asset_processor import ASSET_PROCESSOR_PLATFORM_MAP
  17. # Import fixtures
  18. from ..ap_fixtures.asset_processor_fixture import asset_processor as asset_processor
  19. from ..ap_fixtures.ap_setup_fixture import ap_setup_fixture as ap_setup_fixture
  20. from ..ap_fixtures.ap_config_backup_fixture import ap_config_backup_fixture as ap_config_backup_fixture
  21. from ..ap_fixtures.ap_config_default_platform_fixture \
  22. import ap_config_default_platform_fixture as ap_config_default_platform_fixture
  23. # Import LyShared
  24. import ly_test_tools.o3de.pipeline_utils as utils
  25. from automatedtesting_shared import asset_database_utils as asset_db_utils
  26. logger = logging.getLogger(__name__)
  27. # Helper: variables we will use for parameter values in the test:
  28. targetProjects = ["AutomatedTesting"]
  29. @pytest.fixture
  30. def local_resources(request, workspace, ap_setup_fixture):
  31. ap_setup_fixture["tests_dir"] = os.path.dirname(os.path.realpath(__file__))
  32. @dataclass
  33. @pytest.mark.SUITE_sandbox
  34. class BlackboxAssetTest:
  35. test_name: str
  36. asset_folder: str
  37. override_asset_folder: str = ""
  38. scene_debug_file: str = ""
  39. override_scene_debug_file: str = ""
  40. assets: List[asset_db_utils.DBSourceAsset] = ()
  41. override_assets: List[asset_db_utils.DBSourceAsset] = ()
  42. blackbox_fbx_tests = [
  43. pytest.param(
  44. BlackboxAssetTest(
  45. test_name="OneMeshOneMaterial_RunAP_SuccessWithMatchingProducts",
  46. asset_folder="OneMeshOneMaterial",
  47. scene_debug_file="onemeshonematerial.dbgsg",
  48. assets=[
  49. asset_db_utils.DBSourceAsset(
  50. source_file_name="OneMeshOneMaterial.fbx",
  51. uuid=b"8a9164adb84859be893e18aa819438e1",
  52. jobs=[
  53. asset_db_utils.DBJob(
  54. job_key='Scene compilation',
  55. builder_guid=b'bd8bf65894854fe3830e8ec3a23c35f3',
  56. status=4,
  57. error_count=0,
  58. products=[
  59. asset_db_utils.DBProduct(
  60. product_name='onemeshonematerial/onemeshonematerial.assetinfo.dbg',
  61. sub_id=-1450203600,
  62. asset_type=b'48a78be7b3f244b88aa6f0607e9a75a5'),
  63. asset_db_utils.DBProduct(
  64. product_name='onemeshonematerial/onemeshonematerial.dbgsg',
  65. sub_id=1918494907,
  66. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b'),
  67. asset_db_utils.DBProduct(
  68. product_name='onemeshonematerial/onemeshonematerial.dbgsg.xml',
  69. sub_id=556355570, asset_type=b'51f376140d774f369ac67ed70a0ac868'),
  70. asset_db_utils.DBProduct(
  71. product_name='onemeshonematerial/onemeshonematerial_fbx.procprefab',
  72. sub_id=-1819295853,
  73. asset_type=b'9b7c8459471e4eada3637990cc4065a9'),
  74. asset_db_utils.DBProduct(
  75. product_name='onemeshonematerial/onemeshonematerial_fbx.procprefab.json',
  76. sub_id=-1860036023,
  77. asset_type=b'00000000000000000000000000000000')
  78. ]
  79. )
  80. ]
  81. )
  82. ]
  83. ),
  84. id="32250017",
  85. marks=pytest.mark.test_case_id("C32250017"),
  86. ),
  87. pytest.param(
  88. BlackboxAssetTest(
  89. # Verifies that the soft naming convention feature with level of detail meshes works.
  90. test_name="SoftNamingLOD_RunAP_SuccessWithMatchingProducts",
  91. asset_folder="SoftNamingLOD",
  92. scene_debug_file="lodtest.dbgsg",
  93. assets=[
  94. asset_db_utils.DBSourceAsset(
  95. source_file_name="lodtest.fbx",
  96. uuid=b"44c8627fe2c25aae91fe3ff9547be3b9",
  97. jobs=[
  98. asset_db_utils.DBJob(
  99. job_key='Scene compilation',
  100. builder_guid=b'bd8bf65894854fe3830e8ec3a23c35f3',
  101. status=4,
  102. error_count=0,
  103. products=[
  104. asset_db_utils.DBProduct(
  105. product_name='softnaminglod/lodtest.assetinfo.dbg',
  106. sub_id=1928041548,
  107. asset_type=b'48a78be7b3f244b88aa6f0607e9a75a5'),
  108. asset_db_utils.DBProduct(
  109. product_name='softnaminglod/lodtest.dbgsg',
  110. sub_id=-632012261,
  111. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b'),
  112. asset_db_utils.DBProduct(
  113. product_name='softnaminglod/lodtest.dbgsg.xml',
  114. sub_id=-2036095434,
  115. asset_type=b'51f376140d774f369ac67ed70a0ac868'),
  116. asset_db_utils.DBProduct(
  117. product_name='softnaminglod/lodtest_fbx.procprefab',
  118. sub_id=838906682,
  119. asset_type=b'9b7c8459471e4eada3637990cc4065a9'),
  120. asset_db_utils.DBProduct(
  121. product_name='softnaminglod/lodtest_fbx.procprefab.json',
  122. sub_id=-71923453,
  123. asset_type=b'00000000000000000000000000000000'
  124. )
  125. ]
  126. ),
  127. ]
  128. )
  129. ]
  130. ),
  131. id="33887870",
  132. marks=pytest.mark.test_case_id("33887870"),
  133. ),
  134. pytest.param(
  135. BlackboxAssetTest(
  136. # Verifies that the soft naming convention feature with physics proxies works.
  137. test_name="SoftNamingPhysics_RunAP_SuccessWithMatchingProducts",
  138. asset_folder="SoftNamingPhysics",
  139. scene_debug_file="physicstest.dbgsg",
  140. assets=[
  141. asset_db_utils.DBSourceAsset(
  142. source_file_name="physicstest.fbx",
  143. uuid=b"df957b7918cf5b029806c73f630fa1c8",
  144. jobs=[
  145. asset_db_utils.DBJob(
  146. job_key='Scene compilation',
  147. builder_guid=b'bd8bf65894854fe3830e8ec3a23c35f3',
  148. status=4,
  149. error_count=0,
  150. products=[
  151. asset_db_utils.DBProduct(
  152. product_name='softnamingphysics/physicstest.assetinfo.dbg',
  153. sub_id=-2134016152,
  154. asset_type=b'48a78be7b3f244b88aa6f0607e9a75a5'),
  155. asset_db_utils.DBProduct(
  156. product_name='softnamingphysics/physicstest.dbgsg',
  157. sub_id=-740411732,
  158. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b'),
  159. asset_db_utils.DBProduct(
  160. product_name='softnamingphysics/physicstest.dbgsg.xml',
  161. sub_id=330338417,
  162. asset_type=b'51f376140d774f369ac67ed70a0ac868'),
  163. asset_db_utils.DBProduct(
  164. product_name='softnamingphysics/physicstest.pxmesh',
  165. sub_id=640975857,
  166. asset_type=b'7a2871b95eab4de0a901b0d2c6920ddb'),
  167. asset_db_utils.DBProduct(
  168. product_name='softnamingphysics/physicstest_fbx.procprefab',
  169. sub_id=651014275,
  170. asset_type=b'9b7c8459471e4eada3637990cc4065a9'),
  171. asset_db_utils.DBProduct(
  172. product_name='softnamingphysics/physicstest_fbx.procprefab.json',
  173. sub_id=1124966094,
  174. asset_type=b'00000000000000000000000000000000'
  175. )
  176. ]
  177. ),
  178. ]
  179. )
  180. ]
  181. ),
  182. ),
  183. pytest.param(
  184. BlackboxAssetTest(
  185. test_name="MultipleMeshOneMaterial_RunAP_SuccessWithMatchingProducts",
  186. asset_folder="TwoMeshOneMaterial",
  187. scene_debug_file="multiple_mesh_one_material.dbgsg",
  188. assets=[
  189. asset_db_utils.DBSourceAsset(
  190. source_file_name="multiple_mesh_one_material.fbx",
  191. uuid=b"597618fd497659a1b197a015fe47aa95",
  192. jobs=[
  193. asset_db_utils.DBJob(
  194. job_key='Scene compilation',
  195. builder_guid=b'bd8bf65894854fe3830e8ec3a23c35f3',
  196. status=4,
  197. error_count=0,
  198. products=[
  199. asset_db_utils.DBProduct(
  200. product_name='twomeshonematerial/multiple_mesh_one_material.assetinfo.dbg',
  201. sub_id=-1522579082,
  202. asset_type=b'48a78be7b3f244b88aa6f0607e9a75a5'),
  203. asset_db_utils.DBProduct(
  204. product_name='twomeshonematerial/multiple_mesh_one_material.dbgsg',
  205. sub_id=2077268018,
  206. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b'),
  207. asset_db_utils.DBProduct(
  208. product_name='twomeshonematerial/multiple_mesh_one_material.dbgsg.xml',
  209. sub_id=1321067730,
  210. asset_type=b'51f376140d774f369ac67ed70a0ac868'
  211. )
  212. ]
  213. ),
  214. ]
  215. )
  216. ]
  217. ),
  218. id="34448178",
  219. marks=pytest.mark.test_case_id("C34448178"),
  220. ),
  221. pytest.param(
  222. BlackboxAssetTest(
  223. # Verifies whether multiple meshes can share linked materials
  224. test_name="MultipleMeshLinkedMaterials_RunAP_SuccessWithMatchingProducts",
  225. asset_folder="TwoMeshLinkedMaterials",
  226. scene_debug_file="multiple_mesh_linked_materials.dbgsg",
  227. assets=[
  228. asset_db_utils.DBSourceAsset(
  229. source_file_name="multiple_mesh_linked_materials.fbx",
  230. uuid=b"25d8301c2eef5dc7bded310db8ea608d",
  231. jobs=[
  232. asset_db_utils.DBJob(
  233. job_key='Scene compilation',
  234. builder_guid=b'bd8bf65894854fe3830e8ec3a23c35f3',
  235. status=4,
  236. error_count=0,
  237. products=[
  238. asset_db_utils.DBProduct(
  239. product_name='twomeshlinkedmaterials/multiple_mesh_linked_materials.assetinfo.dbg',
  240. sub_id=-1625296771,
  241. asset_type=b'48a78be7b3f244b88aa6f0607e9a75a5'),
  242. asset_db_utils.DBProduct(
  243. product_name='twomeshlinkedmaterials/multiple_mesh_linked_materials.dbgsg',
  244. sub_id=-1898461950,
  245. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b'),
  246. asset_db_utils.DBProduct(
  247. product_name='twomeshlinkedmaterials/multiple_mesh_linked_materials.dbgsg.xml',
  248. sub_id=-772341513,
  249. asset_type=b'51f376140d774f369ac67ed70a0ac868'),
  250. asset_db_utils.DBProduct(
  251. product_name='twomeshlinkedmaterials/multiple_mesh_linked_materials_fbx.procprefab',
  252. sub_id=-859152125,
  253. asset_type=b'9b7c8459471e4eada3637990cc4065a9'),
  254. asset_db_utils.DBProduct(
  255. product_name='twomeshlinkedmaterials/multiple_mesh_linked_materials_fbx.procprefab.json',
  256. sub_id=-841089725,
  257. asset_type=b'00000000000000000000000000000000'
  258. )
  259. ]
  260. ),
  261. ]
  262. )
  263. ]
  264. ),
  265. id="32250018",
  266. marks=pytest.mark.test_case_id("C32250018"),
  267. ),
  268. pytest.param(
  269. BlackboxAssetTest(
  270. # Verifies a mesh with multiple materials
  271. test_name="SingleMeshMultipleMaterials_RunAP_SuccessWithMatchingProducts",
  272. asset_folder="OneMeshMultipleMaterials",
  273. scene_debug_file="single_mesh_multiple_materials.dbgsg",
  274. assets=[
  275. asset_db_utils.DBSourceAsset(
  276. source_file_name="single_mesh_multiple_materials.fbx",
  277. uuid=b"f08fd585dfa35881b4bf86637da5e858",
  278. jobs=[
  279. asset_db_utils.DBJob(
  280. job_key='Scene compilation',
  281. builder_guid=b'bd8bf65894854fe3830e8ec3a23c35f3',
  282. status=4,
  283. error_count=0,
  284. products=[
  285. asset_db_utils.DBProduct(
  286. product_name='onemeshmultiplematerials/single_mesh_multiple_materials.assetinfo.dbg',
  287. sub_id=-250120843,
  288. asset_type=b'48a78be7b3f244b88aa6f0607e9a75a5'),
  289. asset_db_utils.DBProduct(
  290. product_name='onemeshmultiplematerials/single_mesh_multiple_materials.dbgsg',
  291. sub_id=-262822238,
  292. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b'),
  293. asset_db_utils.DBProduct(
  294. product_name='onemeshmultiplematerials/single_mesh_multiple_materials.dbgsg.xml',
  295. sub_id=1462358160,
  296. asset_type=b'51f376140d774f369ac67ed70a0ac868'),
  297. asset_db_utils.DBProduct(
  298. product_name='onemeshmultiplematerials/single_mesh_multiple_materials_fbx.procprefab',
  299. sub_id=1496946180,
  300. asset_type=b'9b7c8459471e4eada3637990cc4065a9'),
  301. asset_db_utils.DBProduct(
  302. product_name='onemeshmultiplematerials/single_mesh_multiple_materials_fbx.procprefab.json',
  303. sub_id=-537346917,
  304. asset_type=b'00000000000000000000000000000000'
  305. )
  306. ]
  307. ),
  308. ]
  309. )
  310. ]
  311. ),
  312. id="32250020",
  313. marks=pytest.mark.test_case_id("C32250020"),
  314. ),
  315. pytest.param(
  316. BlackboxAssetTest(
  317. test_name="MeshWithVertexColors_RunAP_SuccessWithMatchingProducts",
  318. asset_folder="VertexColor",
  319. scene_debug_file="vertexcolor.dbgsg",
  320. assets=[
  321. asset_db_utils.DBSourceAsset(
  322. source_file_name="VertexColor.fbx",
  323. uuid=b"207e7e1540785a26b064e9be67361cdf",
  324. jobs=[
  325. asset_db_utils.DBJob(
  326. job_key='Scene compilation',
  327. builder_guid=b'bd8bf65894854fe3830e8ec3a23c35f3',
  328. status=4,
  329. error_count=0,
  330. products=[
  331. asset_db_utils.DBProduct(
  332. product_name='vertexcolor/vertexcolor.assetinfo.dbg',
  333. sub_id=-772831195,
  334. asset_type=b'48a78be7b3f244b88aa6f0607e9a75a5'),
  335. asset_db_utils.DBProduct(
  336. product_name='vertexcolor/vertexcolor.dbgsg',
  337. sub_id=-1543877170,
  338. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b'),
  339. asset_db_utils.DBProduct(
  340. product_name='vertexcolor/vertexcolor.dbgsg.xml',
  341. sub_id=1743516586,
  342. asset_type=b'51f376140d774f369ac67ed70a0ac868'),
  343. asset_db_utils.DBProduct(
  344. product_name='vertexcolor/vertexcolor_fbx.procprefab',
  345. sub_id=604991654,
  346. asset_type=b'9b7c8459471e4eada3637990cc4065a9'),
  347. asset_db_utils.DBProduct(
  348. product_name='vertexcolor/vertexcolor_fbx.procprefab.json',
  349. sub_id=-1669533680,
  350. asset_type=b'00000000000000000000000000000000'
  351. )
  352. ]
  353. ),
  354. ]
  355. )
  356. ]
  357. ),
  358. id="35796285",
  359. marks=pytest.mark.test_case_id("C35796285"),
  360. ),
  361. pytest.param(
  362. BlackboxAssetTest(
  363. test_name="MotionTest_RunAP_SuccessWithMatchingProducts",
  364. asset_folder="Motion",
  365. scene_debug_file="Jack_Idle_Aim_ZUp.dbgsg",
  366. assets=[
  367. asset_db_utils.DBSourceAsset(
  368. source_file_name="Jack_Idle_Aim_ZUp.fbx",
  369. uuid=b"eda904ae0e145f8b973d57fc5809918b",
  370. jobs=[
  371. asset_db_utils.DBJob(
  372. job_key='Scene compilation',
  373. builder_guid=b'bd8bf65894854fe3830e8ec3a23c35f3',
  374. status=4,
  375. error_count=0,
  376. products=[
  377. asset_db_utils.DBProduct(
  378. product_name='motion/jack_idle_aim_zup.assetinfo.dbg',
  379. sub_id=-1508868345,
  380. asset_type=b'48a78be7b3f244b88aa6f0607e9a75a5'),
  381. asset_db_utils.DBProduct(
  382. product_name='motion/jack_idle_aim_zup.dbgsg',
  383. sub_id=-517610290,
  384. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b'),
  385. asset_db_utils.DBProduct(
  386. product_name='motion/jack_idle_aim_zup.dbgsg.xml',
  387. sub_id=-817863914,
  388. asset_type=b'51f376140d774f369ac67ed70a0ac868'),
  389. asset_db_utils.DBProduct(
  390. product_name='motion/jack_idle_aim_zup.motion',
  391. sub_id=186392073,
  392. asset_type=b'00494b8e75784ba28b28272e90680787'
  393. )
  394. ]
  395. ),
  396. ]
  397. )
  398. ]
  399. ),
  400. ),
  401. pytest.param(
  402. BlackboxAssetTest(
  403. test_name="ShaderBall_RunAP_SuccessWithMatchingProducts",
  404. asset_folder="ShaderBall",
  405. scene_debug_file="shaderball.dbgsg",
  406. assets=[
  407. asset_db_utils.DBSourceAsset(
  408. source_file_name="shaderball.fbx",
  409. uuid=b"48181ba8038e5193997540fc8dffb06d",
  410. jobs=[
  411. asset_db_utils.DBJob(
  412. job_key='Scene compilation',
  413. builder_guid=b'bd8bf65894854fe3830e8ec3a23c35f3',
  414. status=4,
  415. error_count=0,
  416. products=[
  417. asset_db_utils.DBProduct(
  418. product_name='shaderball/shaderball.assetinfo.dbg',
  419. sub_id=-2030891151,
  420. asset_type=b'48a78be7b3f244b88aa6f0607e9a75a5'),
  421. asset_db_utils.DBProduct(
  422. product_name='shaderball/shaderball.dbgsg',
  423. sub_id=-1607815784,
  424. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b'),
  425. asset_db_utils.DBProduct(
  426. product_name='shaderball/shaderball.dbgsg.xml',
  427. sub_id=-1153118555,
  428. asset_type=b'51f376140d774f369ac67ed70a0ac868'),
  429. asset_db_utils.DBProduct(
  430. product_name='shaderball/shaderball_fbx.procprefab',
  431. sub_id=-1501914312,
  432. asset_type=b'9b7c8459471e4eada3637990cc4065a9'),
  433. asset_db_utils.DBProduct(
  434. product_name='shaderball/shaderball_fbx.procprefab.json',
  435. sub_id=-1464074454,
  436. asset_type=b'00000000000000000000000000000000'
  437. ),
  438. ]
  439. ),
  440. ]
  441. )
  442. ]
  443. ),
  444. ),
  445. pytest.param(
  446. BlackboxAssetTest(
  447. test_name="cubewithline_RunAP_CubeOutputsWithoutLine",
  448. asset_folder="cubewithline",
  449. scene_debug_file="cubewithline.dbgsg",
  450. assets=[
  451. asset_db_utils.DBSourceAsset(
  452. source_file_name="cubewithline.fbx",
  453. uuid=b'1ee8fbf7c1f25b8399395a112e51906c',
  454. jobs=[
  455. asset_db_utils.DBJob(
  456. job_key='Scene compilation',
  457. builder_guid=b'bd8bf65894854fe3830e8ec3a23c35f3',
  458. status=4,
  459. error_count=0,
  460. products=[
  461. asset_db_utils.DBProduct(
  462. product_name='cubewithline/cubewithline.assetinfo.dbg',
  463. sub_id=-1674123269,
  464. asset_type=b'48a78be7b3f244b88aa6f0607e9a75a5'),
  465. asset_db_utils.DBProduct(
  466. product_name='cubewithline/cubewithline.dbgsg',
  467. sub_id=1173066699,
  468. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b'),
  469. asset_db_utils.DBProduct(
  470. product_name='cubewithline/cubewithline.dbgsg.xml',
  471. sub_id=1357518515,
  472. asset_type=b'51f376140d774f369ac67ed70a0ac868'),
  473. asset_db_utils.DBProduct(
  474. product_name='cubewithline/cubewithline_fbx.procprefab',
  475. sub_id=1800163200,
  476. asset_type=b'9b7c8459471e4eada3637990cc4065a9'),
  477. asset_db_utils.DBProduct(
  478. product_name='cubewithline/cubewithline_fbx.procprefab.json',
  479. sub_id=2139660816,
  480. asset_type=b'00000000000000000000000000000000'
  481. ),
  482. ]
  483. ),
  484. ]
  485. )
  486. ]
  487. ),
  488. ),
  489. ]
  490. blackbox_fbx_special_tests = [
  491. pytest.param(
  492. BlackboxAssetTest(
  493. test_name="MultipleMeshMultipleMaterial_MultipleAssetInfo_RunAP_SuccessWithMatchingProducts",
  494. asset_folder="TwoMeshTwoMaterial",
  495. override_asset_folder="OverrideAssetInfoForTwoMeshTwoMaterial",
  496. scene_debug_file="multiple_mesh_multiple_material.dbgsg",
  497. override_scene_debug_file="multiple_mesh_multiple_material_override.dbgsg",
  498. assets=[
  499. asset_db_utils.DBSourceAsset(
  500. source_file_name="multiple_mesh_multiple_material.fbx",
  501. uuid=b"b5915fb874af5c8a866ccabbddb57595",
  502. jobs=[
  503. asset_db_utils.DBJob(
  504. job_key='Scene compilation',
  505. builder_guid=b'bd8bf65894854fe3830e8ec3a23c35f3',
  506. status=4,
  507. error_count=0,
  508. products=[
  509. asset_db_utils.DBProduct(
  510. product_name='twomeshtwomaterial/multiple_mesh_multiple_material.assetinfo.dbg',
  511. sub_id=1718635869,
  512. asset_type=b'48a78be7b3f244b88aa6f0607e9a75a5'),
  513. asset_db_utils.DBProduct(
  514. product_name='twomeshtwomaterial/multiple_mesh_multiple_material.dbgsg',
  515. sub_id=896980093,
  516. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b'),
  517. asset_db_utils.DBProduct(
  518. product_name='twomeshtwomaterial/multiple_mesh_multiple_material.dbgsg.xml',
  519. sub_id=-1556988544,
  520. asset_type=b'51f376140d774f369ac67ed70a0ac868'
  521. )
  522. ]
  523. ),
  524. ]
  525. )
  526. ],
  527. override_assets=[
  528. asset_db_utils.DBSourceAsset(
  529. source_file_name="multiple_mesh_multiple_material.fbx",
  530. uuid=b"b5915fb874af5c8a866ccabbddb57595",
  531. jobs=[
  532. asset_db_utils.DBJob(
  533. job_key='Scene compilation',
  534. builder_guid=b'bd8bf65894854fe3830e8ec3a23c35f3',
  535. status=4,
  536. error_count=0,
  537. products=[
  538. asset_db_utils.DBProduct(
  539. product_name='twomeshtwomaterial/multiple_mesh_multiple_material.assetinfo.dbg',
  540. sub_id=1718635869,
  541. asset_type=b'48a78be7b3f244b88aa6f0607e9a75a5'),
  542. asset_db_utils.DBProduct(
  543. product_name='twomeshtwomaterial/multiple_mesh_multiple_material.dbgsg',
  544. sub_id=896980093,
  545. asset_type=b'07f289d14dc74c4094b40a53bbcb9f0b'),
  546. asset_db_utils.DBProduct(
  547. product_name='twomeshtwomaterial/multiple_mesh_multiple_material.dbgsg.xml',
  548. sub_id=-1556988544,
  549. asset_type=b'51f376140d774f369ac67ed70a0ac868'
  550. )
  551. ]
  552. ),
  553. ]
  554. )
  555. ]
  556. ),
  557. id="34389075",
  558. marks=pytest.mark.test_case_id("C34389075"),
  559. ),
  560. ]
  561. @pytest.mark.usefixtures("asset_processor")
  562. @pytest.mark.usefixtures("ap_setup_fixture")
  563. @pytest.mark.usefixtures("local_resources")
  564. @pytest.mark.parametrize("project", targetProjects)
  565. @pytest.mark.assetpipeline
  566. @pytest.mark.SUITE_sandbox
  567. class TestsFBX_AllPlatforms(object):
  568. @pytest.mark.BAT
  569. @pytest.mark.parametrize("blackbox_param", blackbox_fbx_tests)
  570. def test_FBXBlackboxTest_SourceFiles_Processed_ResultInExpectedProducts(self, workspace, ap_setup_fixture,
  571. asset_processor, project, blackbox_param):
  572. """
  573. Please see run_fbx_test(...) for details
  574. Test Steps:
  575. 1. Determine if blackbox is set to none
  576. 2. Run FBX Test
  577. """
  578. if blackbox_param == None:
  579. return
  580. self.run_fbx_test(workspace, ap_setup_fixture, asset_processor, project, blackbox_param)
  581. @pytest.mark.BAT
  582. @pytest.mark.parametrize("blackbox_param", blackbox_fbx_special_tests)
  583. def test_FBXBlackboxTest_AssetInfoModified_AssetReprocessed_ResultInExpectedProducts(
  584. self, workspace, ap_setup_fixture, asset_processor, project, blackbox_param):
  585. """
  586. Please see run_fbx_test(...) for details
  587. Test Steps:
  588. 1. Determine if blackbox is set to none
  589. 2. Run FBX Test
  590. 2. Re-run FBX test and validate the information in override assets
  591. """
  592. if blackbox_param == None:
  593. return
  594. self.run_fbx_test(workspace, ap_setup_fixture,
  595. asset_processor, project, blackbox_param)
  596. # Run the test again and validate the information in the override assets
  597. self.run_fbx_test(workspace, ap_setup_fixture,
  598. asset_processor, project, blackbox_param, True)
  599. @staticmethod
  600. def populate_asset_info(workspace, project, assets):
  601. # Check that each given source asset resulted in the expected jobs and products.
  602. for expected_source in assets:
  603. for job in expected_source.jobs:
  604. job.platform = ASSET_PROCESSOR_PLATFORM_MAP[workspace.asset_processor_platform]
  605. for product in job.products:
  606. product.product_name = job.platform + "/" \
  607. + product.product_name
  608. @staticmethod
  609. def compare_scene_debug_file(asset_processor, expected_file_path, actual_file_path):
  610. debug_graph_path = os.path.join(asset_processor.project_test_cache_folder(), actual_file_path)
  611. expected_debug_graph_path = os.path.join(asset_processor.project_test_source_folder(), "SceneDebug", expected_file_path)
  612. logger.info(f"Parsing scene graph: {debug_graph_path}")
  613. with open(debug_graph_path, "r") as scene_file:
  614. actual_lines = scene_file.readlines()
  615. logger.info(f"Parsing scene graph: {expected_debug_graph_path}")
  616. with open(expected_debug_graph_path, "r") as scene_file:
  617. expected_lines = scene_file.readlines()
  618. assert utils.compare_lists(actual_lines, expected_lines), "Scene mismatch"
  619. # Helper to run Asset Processor with debug output enabled and Atom output disabled
  620. @staticmethod
  621. def run_ap_debug_skip_atom_output(asset_processor):
  622. result = asset_processor.batch_process(extra_params=["--debugOutput",
  623. "--regset=\"/O3DE/SceneAPI/AssetImporter/SkipAtomOutput=true\""])
  624. assert result, "Asset Processor Failed"
  625. def run_fbx_test(self, workspace, ap_setup_fixture, asset_processor,
  626. project, blackbox_params: BlackboxAssetTest, overrideAsset=False):
  627. """
  628. These tests work by having the test case ingest the test data and determine the run pattern.
  629. Tests will process scene settings files and will additionally do a verification against a provided debug file
  630. Additionally, if an override is passed, the output is checked against the override.
  631. Test Steps:
  632. 1. Create temporary test environment
  633. 2. Process Assets
  634. 3. Determine what assets to validate based upon test data
  635. 4. Validate assets were created in cache
  636. 5. If debug file provided, verify scene files were generated correctly
  637. 6. Verify that each given source asset resulted in the expected jobs and products
  638. """
  639. test_assets_folder = blackbox_params.override_asset_folder if overrideAsset else blackbox_params.asset_folder
  640. logger.info(f"{blackbox_params.test_name}: Processing assets in folder '"
  641. f"{test_assets_folder}' and verifying they match expected output.")
  642. # Prepare test environment and process assets
  643. if not overrideAsset:
  644. asset_processor.prepare_test_environment(ap_setup_fixture['tests_dir'], test_assets_folder)
  645. else:
  646. asset_processor.prepare_test_environment(ap_setup_fixture['tests_dir'], test_assets_folder,
  647. use_current_root=True, add_scan_folder=False,
  648. existing_function_name=blackbox_params.asset_folder)
  649. self.run_ap_debug_skip_atom_output(asset_processor)
  650. logger.info(f"Validating assets.")
  651. assetsToValidate = blackbox_params.override_assets if overrideAsset else blackbox_params.assets
  652. expected_product_list = []
  653. for expected_source in assetsToValidate:
  654. for expected_job in expected_source.jobs:
  655. for expected_product in expected_job.products:
  656. expected_product_list.append(expected_product.product_name)
  657. missing_assets, _ = utils.compare_assets_with_cache(expected_product_list,
  658. asset_processor.project_test_cache_folder())
  659. assert not missing_assets, \
  660. f'The following assets were expected to be in, but not found in cache: {str(missing_assets)}'
  661. # Load the asset database.
  662. db_path = os.path.join(asset_processor.temp_asset_root(), "Cache",
  663. "assetdb.sqlite")
  664. cache_root = os.path.dirname(os.path.join(asset_processor.temp_asset_root(), "Cache",
  665. ASSET_PROCESSOR_PLATFORM_MAP[workspace.asset_processor_platform]))
  666. if blackbox_params.scene_debug_file:
  667. scene_debug_file = blackbox_params.override_scene_debug_file if overrideAsset \
  668. else blackbox_params.scene_debug_file
  669. self.compare_scene_debug_file(asset_processor, scene_debug_file, blackbox_params.scene_debug_file)
  670. # Run again for the .dbgsg.xml file
  671. self.compare_scene_debug_file(asset_processor,
  672. scene_debug_file + ".xml",
  673. blackbox_params.scene_debug_file + ".xml")
  674. # Check that each given source asset resulted in the expected jobs and products.
  675. self.populate_asset_info(workspace, project, assetsToValidate)
  676. for expected_source in assetsToValidate:
  677. for job in expected_source.jobs:
  678. for product in job.products:
  679. asset_db_utils.compare_expected_asset_to_actual_asset(db_path,
  680. expected_source,
  681. f"{blackbox_params.asset_folder}/"
  682. f"{expected_source.source_file_name}",
  683. cache_root)
  684. def test_FBX_ModifiedFBXFile_ConsistentProductOutput_OutputSucceeds(self, workspace, ap_setup_fixture,
  685. asset_processor):
  686. """
  687. Test verifies changing an FBX file with a custom .assetinfo file produces an expected output
  688. The .assetinfo file will remain unchanged.
  689. Test Steps:
  690. 1. Create test environment with an FBX file and a custom .assetinfo file
  691. 2. Launch Asset Processor
  692. 3. Validate that Asset Processor generates the expected output
  693. 4. Modify the FBX file
  694. 5. Run asset processor
  695. 6. Validate that Asset Processor generates the expected output
  696. """
  697. # Copying test assets to project folder
  698. asset_processor.prepare_test_environment(ap_setup_fixture["tests_dir"], "ModifiedFBXFile_ConsistentProductOutput")
  699. # Run AP against the FBX file and the .assetinfo file
  700. self.run_ap_debug_skip_atom_output(asset_processor)
  701. # Set path to expected dbgsg output, copied from test folder
  702. scene_debug_expected = os.path.join(asset_processor.project_test_source_folder(), "SceneDebug", "modifiedfbxfile.dbgsg")
  703. assert os.path.exists(scene_debug_expected), "Expected scene file missing in SceneDebug/modifiedfbxfile.dbgsg - Check test assets"
  704. # Set path to actual dbgsg output, obtained when running AP
  705. scene_debug_actual = os.path.join(asset_processor.temp_project_cache(asset_platform=ASSET_PROCESSOR_PLATFORM_MAP[workspace.asset_processor_platform]), "ModifiedFBXFile_ConsistentProductOutput","modifiedfbxfile.dbgsg")
  706. assert os.path.exists(scene_debug_actual)
  707. # Compare the dbgsg files to ensure expected outputs
  708. self.compare_scene_debug_file(asset_processor, scene_debug_expected, scene_debug_actual)
  709. # Run again for the .dbgsg.xml files
  710. self.compare_scene_debug_file(asset_processor, scene_debug_expected + ".xml", scene_debug_actual + ".xml")
  711. # Remove the files to be replaced from the source test asset folder
  712. filestoremove = [
  713. os.path.join(asset_processor.project_test_source_folder(),"ModifiedFBXFile.fbx"),
  714. scene_debug_expected,
  715. scene_debug_expected + ".xml"
  716. ]
  717. for file in filestoremove:
  718. os.remove(file)
  719. assert not os.path.exists(file), f"File failed to be removed: {file}"
  720. # Add the replacement FBX and expected dbgsg files into the test project
  721. source = os.path.join(ap_setup_fixture["tests_dir"], "Assets",
  722. "Override_ModifiedFBXFile_ConsistentProductOutput")
  723. destination = asset_processor.project_test_source_folder()
  724. # Note: Replace distutils for shutil.copytree("src", "dst", dirs_exist_ok=True) once updated to Python 3.8
  725. distutils.dir_util.copy_tree(source, destination)
  726. assert os.path.exists(scene_debug_expected), \
  727. "Expected scene file missing in SceneDebug/modifiedfbxfile.dbgsg - Check test assets"
  728. # Run AP again to regenerate the .dbgsg files
  729. self.run_ap_debug_skip_atom_output(asset_processor)
  730. # Compare the new .dbgsg files with their expected outputs
  731. self.compare_scene_debug_file(asset_processor, scene_debug_expected, scene_debug_actual)
  732. # Run again for the .dbgsg.xml file
  733. self.compare_scene_debug_file(asset_processor, scene_debug_expected + ".xml", scene_debug_actual + ".xml")
  734. def test_FBX_MixedCaseFileExtension_OutputSucceeds(self, workspace, ap_setup_fixture, asset_processor):
  735. """
  736. Test verifies FBX file with any combination of mixed casing in its file extension produces the
  737. expected output.
  738. Test Steps:
  739. 1. Create test environment with an FBX file
  740. 2. Change the .fbx file extension casing
  741. 2. Launch Asset Processor
  742. 3. Validate that Asset Processor generates the expected output
  743. 4. Modify the FBX file's extension to a different casing
  744. 5. Run asset processor
  745. 6. Validate that Asset Processor generates the expected output
  746. """
  747. extensionlist = [
  748. "OneMeshOneMaterial.Fbx",
  749. "OneMeshOneMaterial.fBX",
  750. "OneMeshOneMaterial.FBX",
  751. ]
  752. original_extension = "OneMeshOneMaterial.fbx"
  753. for extension in extensionlist:
  754. asset_processor.prepare_test_environment(ap_setup_fixture["tests_dir"], "OneMeshOneMaterial")
  755. rename_src = os.path.join(asset_processor.project_test_source_folder(), original_extension)
  756. rename_dst = os.path.join(asset_processor.project_test_source_folder(), extension)
  757. os.rename(rename_src, rename_dst)
  758. assert os.path.exists(rename_dst), "Expected test file missing"
  759. # Run AP while generating debug output and skipping atom output
  760. self.run_ap_debug_skip_atom_output(asset_processor)
  761. expectedassets = [
  762. 'onemeshonematerial/onemeshonematerial.assetinfo.dbg',
  763. 'onemeshonematerial/onemeshonematerial.dbgsg',
  764. 'onemeshonematerial/onemeshonematerial.dbgsg.xml',
  765. 'onemeshonematerial/onemeshonematerial_fbx.procprefab',
  766. 'onemeshonematerial/onemeshonematerial_fbx.procprefab.json'
  767. ]
  768. missing_assets, _ = utils.compare_assets_with_cache(expectedassets,
  769. asset_processor.project_test_cache_folder())
  770. assert not missing_assets, \
  771. f'The following assets were expected to be in when processing {extension}, but not found in cache: ' \
  772. f'{str(missing_assets)}'
  773. scene_debug_expected = os.path.join(asset_processor.project_test_source_folder(), "SceneDebug",
  774. "onemeshonematerial.dbgsg")
  775. assert os.path.exists(scene_debug_expected), \
  776. "Expected scene file missing in SceneDebug/onemeshonematerial.dbgsg - Check test assets"
  777. # Set path to actual dbgsg output, obtained when running AP
  778. scene_debug_actual = os.path.join(asset_processor.temp_project_cache(
  779. asset_platform=ASSET_PROCESSOR_PLATFORM_MAP[workspace.asset_processor_platform]),
  780. "onemeshonematerial", "onemeshonematerial.dbgsg")
  781. assert os.path.exists(scene_debug_actual), f"Scene debug output missing after running AP on {extension}."
  782. self.compare_scene_debug_file(asset_processor, scene_debug_expected, scene_debug_actual)
  783. # Run again for the .dbgsg.xml file
  784. self.compare_scene_debug_file(asset_processor,
  785. scene_debug_expected + ".xml",
  786. scene_debug_actual + ".xml")