Editor_ComponentPropertyCommands_visibility.py 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 os, sys
  7. sys.path.append(os.path.dirname(__file__))
  8. from Editor_TestClass import BaseClass
  9. class Editor_ComponentPropertyCommands_visibility(BaseClass):
  10. # Description:
  11. # ComponentPropertyCommands test case visibility
  12. @staticmethod
  13. def test():
  14. import azlmbr.bus as bus
  15. import azlmbr.editor as editor
  16. import azlmbr.legacy.general
  17. import azlmbr.entity as entity
  18. check_result = BaseClass.check_result
  19. # Find entity
  20. searchFilter = entity.SearchFilter()
  21. searchFilter.names = ["Shader Ball"]
  22. entityId = entity.SearchBus(bus.Broadcast, 'SearchEntities', searchFilter)[0]
  23. check_result(entityId, "entityId was found")
  24. # Find Mesh component
  25. typeIdsList = editor.EditorComponentAPIBus(bus.Broadcast, 'FindComponentTypeIdsByEntityType', ['Mesh'], entity.EntityType().Game)
  26. getComponentOutcome = editor.EditorComponentAPIBus(bus.Broadcast, 'GetComponentOfType', entityId, typeIdsList[0])
  27. check_result(getComponentOutcome.IsSuccess(), "Found component")
  28. componentId = getComponentOutcome.GetValue()
  29. # Get the PTE from the Mesh Component
  30. pteObj = editor.EditorComponentAPIBus(bus.Broadcast, 'BuildComponentPropertyTreeEditor', componentId)
  31. check_result(pteObj.IsSuccess(), "Created a PropertyTreeEditor for the Mesh component")
  32. pte = pteObj.GetValue()
  33. paths = pte.build_paths_list_with_types()
  34. # test for visibility (default all nodes are exposed)
  35. check_result(pte.get_value('Controller|Configuration|Model Asset').IsSuccess(), "Found property hidden node in path")
  36. # enable visibility enforcement
  37. pte.set_visible_enforcement(True)
  38. paths = pte.build_paths_list_with_types()
  39. check_result(pte.get_value('Controller|Configuration|Model Asset').IsSuccess() is not True, "Property Controller|Configuration| is now a hidden path")
  40. # test for visibility (missing some property paths parts now)
  41. check_result(pte.get_value('Model Asset').IsSuccess(), "Property path enforcement of visibility")
  42. if __name__ == "__main__":
  43. tester = Editor_ComponentPropertyCommands_visibility()
  44. tester.test_case(tester.test, level="TestDependenciesLevel")