AssetBuilder_test_case.py 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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 azlmbr.bus
  7. import azlmbr.asset
  8. import azlmbr.editor
  9. import azlmbr.math
  10. print('Starting mock asset tests')
  11. handler = azlmbr.editor.EditorEventBusHandler()
  12. def on_notify_editor_initialized(args):
  13. # These tests are meant to check that the test_asset.mock source asset turned into
  14. # a test_asset.mock_asset product asset via the Python asset builder system
  15. mockAssetType = azlmbr.math.Uuid_CreateString('{9274AD17-3212-4651-9F3B-7DCCB080E467}')
  16. mockAssetPath = 'gem/pythontests/pythonassetbuilder/test_asset.mock_asset'
  17. assetId = azlmbr.asset.AssetCatalogRequestBus(azlmbr.bus.Broadcast, 'GetAssetIdByPath', mockAssetPath, mockAssetType, False)
  18. if (assetId.is_valid() is False):
  19. print(f'Mock AssetId is not valid! Got {assetId.to_string()} instead')
  20. else:
  21. print(f'Mock AssetId is valid!')
  22. assetIdString = assetId.to_string()
  23. if (assetIdString.endswith(':528cca58') is False):
  24. print(f'Mock AssetId {assetIdString} has unexpected sub-id for {mockAssetPath}!')
  25. else:
  26. print(f'Mock AssetId has expected sub-id for {mockAssetPath}!')
  27. print ('Mock asset exists')
  28. # These tests detect if the geom_group.fbx file turns into a number of azmodel product assets
  29. def test_azmodel_product(generatedModelAssetPath):
  30. azModelAssetType = azlmbr.math.Uuid_CreateString('{2C7477B6-69C5-45BE-8163-BCD6A275B6D8}')
  31. assetId = azlmbr.asset.AssetCatalogRequestBus(azlmbr.bus.Broadcast, 'GetAssetIdByPath', generatedModelAssetPath, azModelAssetType, False)
  32. assetIdString = assetId.to_string()
  33. if (assetId.is_valid()):
  34. print(f'AssetId found for asset ({generatedModelAssetPath}) found')
  35. else:
  36. print(f'Asset at path {generatedModelAssetPath} has unexpected asset ID ({assetIdString})!')
  37. test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_positive.fbx.azmodel')
  38. test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_z_negative.fbx.azmodel')
  39. test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_positive.fbx.azmodel')
  40. test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_y_negative.fbx.azmodel')
  41. test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_positive.fbx.azmodel')
  42. test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_x_negative.fbx.azmodel')
  43. test_azmodel_product('gem/pythontests/pythonassetbuilder/geom_group_fbx_cube_100cm_center.fbx.azmodel')
  44. # clear up notification handler
  45. global handler
  46. handler.disconnect()
  47. handler = None
  48. print('Finished mock asset tests')
  49. azlmbr.editor.EditorToolsApplicationRequestBus(azlmbr.bus.Broadcast, 'ExitNoPrompt')
  50. handler.connect()
  51. handler.add_callback('NotifyEditorInitialized', on_notify_editor_initialized)