MetadataRelocation_ReferenceValidAfterRename.py 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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. # Test Case Title : Check that renaming a material maintains references
  7. class Results:
  8. material = ("Correct material", "Incorrect material")
  9. def MetadataRelocation_ReferenceValidAfterRename():
  10. # Description: This test checks that renaming an asset and its metadata retains the same UUID and does not break
  11. # existing references. This specifically tests the material component
  12. # Import report and test helper utilities
  13. from editor_python_test_tools.utils import Report
  14. from editor_python_test_tools.utils import TestHelper as helper
  15. # All exposed python bindings are in azlmbr
  16. import azlmbr.bus as bus
  17. import azlmbr.editor as editor
  18. import azlmbr.legacy.general as general
  19. import azlmbr.globals as globals
  20. import azlmbr.default
  21. import azlmbr.render
  22. import azlmbr.asset
  23. # Required for automated tests
  24. helper.init_idle()
  25. # Open the level called "MetadataTest".
  26. # This level contains a test entity with a reference to the material
  27. helper.open_level("", "MetadataTest")
  28. bunny_entity = general.find_editor_entity("Bunny")
  29. base_color = azlmbr.render.MaterialComponentRequestBus(bus.Event, "GetPropertyValueColor",
  30. bunny_entity, azlmbr.render.DefaultMaterialAssignmentId,
  31. "baseColor.color")
  32. color_code = base_color.ToU32()
  33. # This is a specific color set on the material assigned to the bunny
  34. expected_color_code = 4289747234
  35. is_correct_asset = color_code == expected_color_code
  36. Report.result(Results.material, is_correct_asset)
  37. if __name__ == "__main__":
  38. # This utility starts up the test and sets up the state for knowing what test is currently being run
  39. from editor_python_test_tools.utils import Report
  40. Report.start_test(MetadataRelocation_ReferenceValidAfterRename)